List of usage examples for java.util Hashtable get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:edu.ku.brc.specify.utilapps.RegProcessor.java
/** * @param key/*w w w . j a v a2 s . c o m*/ * @param valueStr */ protected void addToTracks(final String key, final String valueStr, final Hashtable<String, Boolean> trackUsageHashArg, final Hashtable<String, Hashtable<String, Integer>> trackCatsHashArg) { trackUsageHashArg.put(key, true); String category = getCategoryKey(key); if (category != null) { Hashtable<String, Integer> countHash = trackCatsHashArg.get(category); if (countHash == null) { countHash = new Hashtable<String, Integer>(); trackCatsHashArg.put(category, countHash); } Integer count = countHash.get(key); int valNum = Integer.parseInt(valueStr); if (count == null) { count = valNum; } else { count += valNum; } countHash.put(key, count); } }
From source file:fedora.server.access.dissemination.DisseminationService.java
/** * <p>/* w ww. j a v a 2s . c om*/ * Datastream locations are considered privileged information by the Fedora * repository. To prevent disclosing physical datastream locations to * external mechanism services, a proxy is used to disguise the datastream * locations. This method generates a temporary ID that maps to the physical * datastream location and registers this information in a memory resident * hashtable for subsequent resolution of the physical datastream location. * The servlet <code>DatastreamResolverServlet</code> provides the proxy * resolution service for datastreams. * </p> * <p> * </p> * <p> * The format of the tempID is derived from <code>java.sql.Timestamp</code> * with an arbitrary counter appended to the end to insure uniqueness. The * syntax is of the form: * <ul> * <p> * YYYY-MM-DD HH:mm:ss.mmm:dddddd where * </p> * <ul> * <li>YYYY - year (1900-8099)</li> * <li>MM - month (01-12)</li> * <li>DD - day (01-31)</li> * <li>hh - hours (0-23)</li> * <li>mm - minutes (0-59)</li> * <li>ss - seconds (0-59)</li> * <li>mmm - milliseconds (0-999)</li> * <li>dddddd - incremental counter (0-999999)</li> * </ul> * </ul> * * @param dsLocation * The physical location of the datastream. * @param dsControlGroupType * The type of the datastream. * @return A temporary ID used to reference the physical location of the * specified datastream * @throws ServerException * If an error occurs in registering a datastream location. */ public String registerDatastreamLocation(String dsLocation, String dsControlGroupType, String beServiceCallbackRole, String methodName) throws ServerException { String tempID = null; Timestamp timeStamp = null; if (counter > 999999) { counter = 0; } long currentTime = new Timestamp(new Date().getTime()).getTime(); long expireLimit = currentTime - (long) datastreamExpirationLimit * 1000; String dsMediatedServletPath = null; String dsMediatedCallbackHost = null; try { // Remove any datastream registrations that have expired. // The expiration limit can be adjusted using the Fedora config parameter // named "datastreamExpirationLimit" which is in seconds. for (Enumeration e = dsRegistry.keys(); e.hasMoreElements();) { String key = (String) e.nextElement(); timeStamp = Timestamp.valueOf(extractTimestamp(key)); if (expireLimit > timeStamp.getTime()) { dsRegistry.remove(key); LOG.debug("DatastreamMediationKey removed from Hash: " + key); } } // Register datastream. if (tempID == null) { timeStamp = new Timestamp(new Date().getTime()); tempID = timeStamp.toString() + ":" + counter++; DatastreamMediation dm = new DatastreamMediation(); dm.mediatedDatastreamID = tempID; dm.dsLocation = dsLocation; dm.dsControlGroupType = dsControlGroupType; dm.methodName = methodName; // See if datastream reference is to fedora server itself or an external location. // M and X type datastreams always reference fedora server. With E type datastreams // we must examine URL to see if this is referencing a remote datastream or is // simply a callback to the fedora server. If the reference is remote, then use // the role of the backend service that will make a callback for this datastream. // If the referenc s to the fedora server, use the special role of "fedoraInternalCall-1" to // denote that the callback will come from the fedora server itself. String beServiceRole = null; if (ServerUtility.isURLFedoraServer(dsLocation) || dsControlGroupType.equals("M") || dsControlGroupType.equals("X")) { beServiceRole = BackendPolicies.FEDORA_INTERNAL_CALL; } else { beServiceRole = beServiceCallbackRole; } // Store beSecurity info in hash Hashtable beHash = m_beSS.getSecuritySpec(beServiceRole, methodName); boolean beServiceCallbackBasicAuth = new Boolean((String) beHash.get("callbackBasicAuth")) .booleanValue(); boolean beServiceCallBasicAuth = new Boolean((String) beHash.get("callBasicAuth")).booleanValue(); boolean beServiceCallbackSSL = new Boolean((String) beHash.get("callbackSSL")).booleanValue(); boolean beServiceCallSSL = new Boolean((String) beHash.get("callSSL")).booleanValue(); String beServiceCallUsername = (String) beHash.get("callUsername"); String beServiceCallPassword = (String) beHash.get("callPassword"); if (LOG.isDebugEnabled()) { LOG.debug("******************Registering datastream dsLocation: " + dsLocation); LOG.debug("******************Registering datastream dsControlGroupType: " + dsControlGroupType); LOG.debug("******************Registering datastream beServiceRole: " + beServiceRole); LOG.debug("******************Registering datastream beServiceCallbackBasicAuth: " + beServiceCallbackBasicAuth); LOG.debug("******************Registering datastream beServiceCallBasicAuth: " + beServiceCallBasicAuth); LOG.debug("******************Registering datastream beServiceCallbackSSL: " + beServiceCallbackSSL); LOG.debug("******************Registering datastream beServiceCallSSL: " + beServiceCallSSL); LOG.debug("******************Registering datastream beServiceCallUsername: " + beServiceCallUsername); LOG.debug("******************Registering datastream beServiceCallPassword: " + beServiceCallPassword); } dm.callbackRole = beServiceRole; dm.callUsername = beServiceCallUsername; dm.callPassword = beServiceCallPassword; dm.callbackBasicAuth = beServiceCallbackBasicAuth; dm.callBasicAuth = beServiceCallBasicAuth; dm.callbackSSL = beServiceCallbackSSL; dm.callSSL = beServiceCallSSL; dsRegistry.put(tempID, dm); LOG.debug("DatastreammediationKey added to Hash: " + tempID); } } catch (Throwable th) { throw new DisseminationException("[DisseminationService] register" + "DatastreamLocation: " + "returned an error. The underlying error was a " + th.getClass().getName() + " The message " + "was \"" + th.getMessage() + "\" ."); } // Replace the blank between date and time with the character "T". return tempID.replaceAll(" ", "T"); }
From source file:com.autentia.intra.manager.billing.BillManager.java
/** * Account DAO *//ww w. j av a 2s .c o m */ public List<BillBreakDown> getAllBitacoreBreakDowns(Date start, Date end, Set<ProjectRole> roles, Set<ProjectCost> costes) { List<BillBreakDown> desgloses = new ArrayList<BillBreakDown>(); ActivityDAO activityDAO = ActivityDAO.getDefault(); ActivitySearch actSearch = new ActivitySearch(); actSearch.setBillable(new Boolean(true)); actSearch.setStartStartDate(start); actSearch.setEndStartDate(end); List<Activity> actividadesTotal = new ArrayList<Activity>(); Hashtable user_roles = new Hashtable(); for (ProjectRole proyRole : roles) { actSearch.setRole(proyRole); List<Activity> actividades = activityDAO.search(actSearch, new SortCriteria("startDate", false)); actividadesTotal.addAll(actividades); } for (Activity act : actividadesTotal) { String key = act.getRole().getId().toString() + act.getUser().getId().toString(); if (!user_roles.containsKey(key)) { Hashtable value = new Hashtable(); value.put("ROLE", act.getRole()); value.put("USER", act.getUser()); user_roles.put(key, value); } } Enumeration en = user_roles.keys(); while (en.hasMoreElements()) { String key = (String) en.nextElement(); Hashtable pair = (Hashtable) user_roles.get(key); actSearch.setBillable(new Boolean(true)); actSearch.setStartStartDate(start); actSearch.setEndStartDate(end); ProjectRole pR = (ProjectRole) pair.get("ROLE"); User u = (User) pair.get("USER"); actSearch.setRole(pR); actSearch.setUser(u); List<Activity> actividadesUsuarioRol = activityDAO.search(actSearch, new SortCriteria("startDate", false)); BillBreakDown brd = new BillBreakDown(); brd.setConcept("Imputaciones (usuario - rol): " + u.getName() + " - " + pR.getName()); brd.setAmount(pR.getCostPerHour()); brd.setIva(new BigDecimal(ConfigurationUtil.getDefault().getIva())); BigDecimal unitsTotal = new BigDecimal(0); for (Activity act : actividadesUsuarioRol) { BigDecimal unitsActual = new BigDecimal(act.getDuration()); unitsActual = unitsActual.divide(new BigDecimal(60), 2, RoundingMode.HALF_UP); unitsTotal = unitsTotal.add(unitsActual); } brd.setUnits(unitsTotal); brd.setSelected(true); desgloses.add(brd); } for (ProjectCost proyCost : costes) { BillBreakDown brd = new BillBreakDown(); brd.setConcept("Coste: " + proyCost.getName()); brd.setUnits(new BigDecimal(1)); brd.setAmount(proyCost.getCost()); brd.setIva(new BigDecimal(ConfigurationUtil.getDefault().getIva())); brd.setSelected(true); desgloses.add(brd); } return desgloses; }
From source file:net.oauth.j2me.OAuthMessage.java
public String normalizeRequestParameters() { System.out.println("in normalizeRequestParameters"); String normalizedRequestParameters = ""; Hashtable h = Util.hashtableMerge(this.convertToKeyValuePairs(), requestParameters); System.out.println("made it past hmerge"); Enumeration keys = Util.sort(h.keys()); System.out.println("made it past sort"); OAuthParameterEncoder encoder = new OAuthParameterEncoder(); try {//from ww w . j av a2 s . co m String key = ""; while (keys.hasMoreElements()) { try { key = (String) keys.nextElement(); if (!"".equals(normalizedRequestParameters)) { normalizedRequestParameters += "&"; } normalizedRequestParameters += encoder.encode(key) + "=" + encoder.encode((String) h.get(key)); //normalizedRequestParameters += key + "=" + (String) h.get(key); } catch (java.util.NoSuchElementException e) { ; } } } catch (NullPointerException e) { ; } catch (Exception e) { ; } System.out.println("normalized parmas=" + normalizedRequestParameters); return normalizedRequestParameters; }
From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java
JFreeChart labChartRef(String demographicNo, String typeIdName, String typeIdName2, String patientName, String chartTitle) {/*ww w. j av a 2 s. c o m*/ org.jfree.data.time.TimeSeriesCollection dataset = new org.jfree.data.time.TimeSeriesCollection(); ArrayList<EctMeasurementsDataBean> list = getList(demographicNo, typeIdName); String typeYAxisName = ""; ArrayList<OHLCDataItem> dataItems = new ArrayList<OHLCDataItem>(); if (typeIdName.equals("BP")) { log.debug("Using BP LOGIC FOR type 1 "); EctMeasurementsDataBean sampleLine = list.get(0); typeYAxisName = sampleLine.getTypeDescription(); TimeSeries systolic = new TimeSeries("Systolic", Day.class); TimeSeries diastolic = new TimeSeries("Diastolic", Day.class); for (EctMeasurementsDataBean mdb : list) { // dataVector) { String[] str = mdb.getDataField().split("/"); systolic.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(str[0])); diastolic.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(str[1])); } dataset.addSeries(diastolic); dataset.addSeries(systolic); } else { log.debug("Not Using BP LOGIC FOR type 1 "); // get the name from the TimeSeries EctMeasurementsDataBean sampleLine = list.get(0); String typeLegendName = sampleLine.getTypeDisplayName(); typeYAxisName = sampleLine.getTypeDescription(); // this should be the type of measurement TimeSeries newSeries = new TimeSeries(typeLegendName, Day.class); for (EctMeasurementsDataBean mdb : list) { //dataVector) { newSeries.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(mdb.getDataField())); try { Hashtable h = getMeasurementsExt(mdb.getId()); if (h != null && h.containsKey("minimum")) { String min = (String) h.get("minimum"); String max = (String) h.get("maximum"); double open = Double.parseDouble(min.trim()); double high = Double.parseDouble(max.trim()); double low = Double.parseDouble(min.trim()); double close = Double.parseDouble(max.trim()); double volume = 1045; dataItems .add(new OHLCDataItem(mdb.getDateObservedAsDate(), open, high, low, close, volume)); } } catch (Exception et) { MiscUtils.getLogger().error("Error", et); } } dataset.addSeries(newSeries); } JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Days", typeYAxisName, dataset, true, true, true); XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setAutoRange(true); log.debug("LEN " + plot.getDomainAxis().getLowerBound() + " ddd " + plot.getDomainAxis().getUpperMargin() + " eee " + plot.getDomainAxis().getLowerMargin()); plot.getDomainAxis().setUpperMargin(plot.getDomainAxis().getUpperMargin() * 6); plot.getDomainAxis().setLowerMargin(plot.getDomainAxis().getLowerMargin() * 6); plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 1.7); plot.getDomainAxis().setUpperMargin(0.9); plot.getDomainAxis().setLowerMargin(0.9); plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 4); ValueAxis va = plot.getRangeAxis(); va.setAutoRange(true); XYItemRenderer renderer = plot.getRenderer(); //DateFormat.getInstance() XYItemLabelGenerator generator = new StandardXYItemLabelGenerator("{1} \n {2}", new SimpleDateFormat("yyyy.MM.dd"), new DecimalFormat("0.00")); renderer.setSeriesItemLabelGenerator(0, generator);//setLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); plot.setBackgroundPaint(Color.WHITE); plot.setDomainCrosshairPaint(Color.GRAY); if (renderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer rend = (XYLineAndShapeRenderer) renderer; rend.setBaseShapesVisible(true); rend.setBaseShapesFilled(true); } plot.setRenderer(renderer); if (dataItems != null && dataItems.size() > 0) { OHLCDataItem[] ohlc = dataItems.toArray(new OHLCDataItem[dataItems.size()]); XYDataset referenceRangeDataset = new DefaultOHLCDataset("Reference Range", ohlc); plot.setRenderer(1, setAxisAndDataSet(1, plot, plot.getRangeAxis(), referenceRangeDataset, Color.GREEN, new HighLowRenderer())); } ///// return chart; }
From source file:javanews.gui.internalframe.LinkChart.java
/** * Initialises the class and internal logger. Uses the supplied arguments to * receive data from the application and add data to the charts dynamically. * @param title The title of the charts on display. Whether the displayed * data is for <code>new</code> or <code>old</code> links. * That is whether the data is for newly discovered links or * existing (old) links already stored within the database. * @param parent The instance of <code>COMPortClient</code> that acts as * the data source for the charts. *///w w w .j a va 2s. c o m public LinkChart(String title, COMPortClient parent) { super("Charts", true, true, true, true); super.setLayer(1); identifier = title.toLowerCase(); // Obtain an instance of Logger for the class log = LoggerFactory.getLogger(className); owner = parent; // Setup a hashtable to hold the values for up, down and unknown link states Hashtable<String, Integer> linkStats = new Hashtable<String, Integer>(); if (identifier.equals("old")) { this.setTitle("Recognised Link Status on " + owner.getPortName() + ":"); // Get the current figures from the link table linkStats = ((LinkTable) owner.getLinkTable().getModel()).getInitialFigures(); } else if (identifier.equals("new")) { this.setTitle("Discovered Link Status on " + owner.getPortName() + ":"); linkStats = ((LinkTable) owner.getNewLinkTable().getModel()).getInitialFigures(); } else { // If the identifier was set to something other than old or new then it's not right. log.warning("An instance of LinkChart has been created for an unknown purpose."); return; } // Initialise the dataset for the pie chart dpdCurrentData = new DefaultPieDataset(); dpdCurrentData.insertValue(0, "Link Down", linkStats.get("down")); dpdCurrentData.insertValue(1, "Link Up", linkStats.get("up")); dpdCurrentData.insertValue(2, "Link State Unknown", linkStats.get("unknown")); // Initialise the dataset for the line chart dcdPreviousData = new DefaultCategoryDataset(); dcdPreviousData.addValue(linkStats.get("down"), "Link Down", Calendar.getInstance().getTime().toString()); dcdPreviousData.addValue(linkStats.get("up"), "Link Up", Calendar.getInstance().getTime().toString()); dcdPreviousData.addValue(linkStats.get("unknown"), "Link State Unknown", Calendar.getInstance().getTime().toString()); // Set the variables we need for holding the charts JFreeChart jfcCurrentStatus; // This will be displayed as a pie chart JFreeChart jfcPreviousStatus; // This will be displayed as a line chart ChartPanel cpCurrent; // Chartpanels hold the JFreeChart ChartPanel cpPrevious; // Use the factory to create the charts jfcCurrentStatus = ChartFactory.createPieChart("Current Status", dpdCurrentData, true, true, false); jfcPreviousStatus = ChartFactory.createLineChart("Previous Status", "Time received", "Number of Links", dcdPreviousData, PlotOrientation.VERTICAL, true, true, false); // Add them to the chart panels cpCurrent = new ChartPanel(jfcCurrentStatus); cpPrevious = new ChartPanel(jfcPreviousStatus); // Add the chart panels to the content pane this.add(cpCurrent, BorderLayout.EAST); this.add(cpPrevious, BorderLayout.WEST); // Change the layout to show them next to each other this.setLayout(new GridLayout(1, 2)); // Add a listener to the window this.addInternalFrameListener(new CloseLinkChart(this)); log.finest("Adding frame to the desktop"); // Set the window properties and display it Client.getJNWindow().addToDesktop(this); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.setSize(650, 400); this.setVisible(true); owner.addChartWindow(title, this); }
From source file:oscar.dms.actions.DmsInboxManageAction.java
private void setProviderDocsInSession(ArrayList<EDoc> privatedocs, HttpServletRequest request) { ArrayList<Hashtable<String, String>> providers = ProviderData.getProviderListOfAllTypes(); Hashtable<String, List<EDoc>> providerDocs = new Hashtable<String, List<EDoc>>(); for (int i = 0; i < providers.size(); i++) { Hashtable<String, String> ht = providers.get(i); List<EDoc> EDocs = new ArrayList<EDoc>(); String providerNo = ht.get("providerNo"); providerDocs.put(providerNo, EDocs); }// w w w . j av a 2 s . c o m for (int i = 0; i < privatedocs.size(); i++) { EDoc eDoc = privatedocs.get(i); List<String> providerList = new ArrayList<String>(); String createrId = eDoc.getCreatorId(); if (providerDocs.containsKey(createrId)) { List<EDoc> EDocs = new ArrayList<EDoc>(); EDocs = providerDocs.get(createrId); EDocs.add(eDoc); providerDocs.put(createrId, EDocs); } String docId = eDoc.getDocId(); providerList.add(createrId); List<ProviderInboxItem> routeList = providerInboxRoutingDAO .getProvidersWithRoutingForDocument(LabResultData.DOCUMENT, docId); for (ProviderInboxItem pii : routeList) { String routingPId = pii.getProviderNo(); if (!routingPId.equals(createrId) && providerDocs.containsKey(routingPId)) { List<EDoc> EDocs = new ArrayList<EDoc>(); EDocs = providerDocs.get(routingPId); EDocs.add(eDoc); providerDocs.put(routingPId, EDocs); } } } // remove providers which has no docs linked to Enumeration<String> keys = providerDocs.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); List<EDoc> EDocs = new ArrayList<EDoc>(); EDocs = providerDocs.get(key); if (EDocs == null || EDocs.size() == 0) { providerDocs.remove(key); } } request.getSession().setAttribute("providerDocs", providerDocs); }
From source file:com.flexive.ejb.beans.workflow.StepEngineBean.java
/** * {@inheritDoc}//from w w w . j ava2 s.co m */ @Override public List<StepPermission> loadAllStepsForUser(long userId) throws FxApplicationException { UserTicket ticket = FxContext.getUserTicket(); // Select all step ids final String sql = // 1 , 2 , 3 "SELECT DISTINCT step.ID,aclug.ACL,step.WORKFLOW," // 4 , 5 , 6 , 7 , 8 , 9 , 10 + " aclug.PEDIT,aclug.PREAD,aclug.PREMOVE,aclug.PEXPORT,aclug.PREL,aclug.PCREATE,step.STEPDEF" + " FROM " + TBL_ACLS + " acl," + TBL_ACLS_ASSIGNMENT + " aclug," + TBL_WORKFLOW_STEP + " step" + " WHERE" + " aclug.ACL=acl.ID" + " AND acl.CAT_TYPE=" + ACLCategory.WORKFLOW.getId() + " AND aclug.USERGROUP IN (SELECT DISTINCT USERGROUP FROM " + TBL_ASSIGN_GROUPS + " WHERE ACCOUNT=" + userId + " AND USERGROUP<>" + UserGroup.GROUP_OWNER + ")" + " AND step.ACL=acl.ID"; // Security if (!ticket.isGlobalSupervisor()) { if (ticket.getUserId() != userId) { FxNoAccessException na = new FxNoAccessException("You may not load the Steps for a other user"); if (LOG.isInfoEnabled()) LOG.info(na); throw na; } } // Obtain a database connection Connection con = null; Statement stmt = null; try { con = Database.getDbConnection(); // Load all steps in the database stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(sql); //ArrayList result = new ArrayList(50); Hashtable<Integer, StepPermission> result = new Hashtable<Integer, StepPermission>(50); while (rs != null && rs.next()) { // Fill in a step object Integer stepId = rs.getInt(1); int workflowId = rs.getInt(3); boolean mayEdit = rs.getBoolean(4); boolean mayRead = rs.getBoolean(5); boolean mayDelete = rs.getBoolean(6); boolean mayExport = rs.getBoolean(7); boolean mayRelate = rs.getBoolean(8); boolean mayCreate = rs.getBoolean(9); int stepDefinitionId = rs.getInt(10); StepPermissionEdit data; StepPermission stepPerm = result.get(stepId); if (stepPerm == null) { data = new StepPermissionEdit(new StepPermission(stepId, stepDefinitionId, workflowId, mayRead, mayEdit, mayRelate, mayDelete, mayExport, mayCreate)); } else { data = new StepPermissionEdit(stepPerm); if (mayDelete) data.setMayDelete(true); if (mayEdit) data.setMayEdit(true); if (mayExport) data.setMayExport(true); if (mayRelate) data.setMayRelate(true); if (mayRead) data.setMayRead(true); if (mayCreate) data.setMayCreate(true); } result.put(stepId, data); } return new ArrayList<StepPermission>(result.values()); } catch (SQLException exc) { throw new FxLoadException(LOG, "ex.step.load.user", exc, userId, exc.getMessage()); } finally { Database.closeObjects(StepEngineBean.class, con, stmt); } }
From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java
JFreeChart referenceRangeChart(String demographicNo, String typeIdName, String typeIdName2, String patientName, String chartTitle) {//ww w .j av a2s .c o m org.jfree.data.time.TimeSeriesCollection dataset = new org.jfree.data.time.TimeSeriesCollection(); ArrayList<EctMeasurementsDataBean> list = getList(demographicNo, typeIdName); ArrayList<OHLCDataItem> dataItems = new ArrayList<OHLCDataItem>(); String typeYAxisName = ""; if (typeIdName.equals("BP")) { log.debug("Using BP LOGIC FOR type 1 "); EctMeasurementsDataBean sampleLine = list.get(0); typeYAxisName = sampleLine.getTypeDescription(); TimeSeries systolic = new TimeSeries("Systolic", Day.class); TimeSeries diastolic = new TimeSeries("Diastolic", Day.class); for (EctMeasurementsDataBean mdb : list) { // dataVector) { String[] str = mdb.getDataField().split("/"); systolic.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(str[0])); diastolic.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(str[1])); } dataset.addSeries(diastolic); dataset.addSeries(systolic); } else { log.debug("Not Using BP LOGIC FOR type 1 "); // get the name from the TimeSeries EctMeasurementsDataBean sampleLine = list.get(0); String typeLegendName = sampleLine.getTypeDisplayName(); typeYAxisName = sampleLine.getTypeDescription(); // this should be the type of measurement TimeSeries newSeries = new TimeSeries(typeLegendName, Day.class); for (EctMeasurementsDataBean mdb : list) { //dataVector) { newSeries.addOrUpdate(new Day(mdb.getDateObservedAsDate()), Double.parseDouble(mdb.getDataField())); try { Hashtable h = getMeasurementsExt(mdb.getId()); if (h != null && h.containsKey("minimum")) { String min = (String) h.get("minimum"); String max = (String) h.get("maximum"); double open = Double.parseDouble(min.trim()); double high = Double.parseDouble(max.trim()); double low = Double.parseDouble(min.trim()); double close = Double.parseDouble(max.trim()); double volume = 1045; dataItems .add(new OHLCDataItem(mdb.getDateObservedAsDate(), open, high, low, close, volume)); } } catch (Exception et) { MiscUtils.getLogger().error("Error", et); } } dataset.addSeries(newSeries); } OHLCDataItem[] ohlc = dataItems.toArray(new OHLCDataItem[dataItems.size()]); JFreeChart chart = ChartFactory.createHighLowChart("HighLowChartDemo2", "Time", "Value", new DefaultOHLCDataset("DREFERENCE RANGE", ohlc), true); XYPlot plot = (XYPlot) chart.getPlot(); // HighLowRenderer renderer = (HighLowRenderer) plot.getRenderer(); // renderer. // renderer.setOpenTickPaint(Color.green); // renderer.setCloseTickPaint(Color.black); plot.setDataset(1, dataset); plot.getDomainAxis().setAutoRange(true); log.debug("LEN " + plot.getDomainAxis().getLowerBound() + " ddd " + plot.getDomainAxis().getUpperMargin() + " eee " + plot.getDomainAxis().getLowerMargin()); //plot.getDomainAxis().setUpperMargin(plot.getDomainAxis().getUpperMargin()*6); //plot.getDomainAxis().setLowerMargin(plot.getDomainAxis().getLowerMargin()*6); // plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin()*1.7); plot.getDomainAxis().setUpperMargin(0.9); plot.getDomainAxis().setLowerMargin(0.9); plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 4); ValueAxis va = plot.getRangeAxis(); va.setAutoRange(true); XYItemRenderer renderer = plot.getRenderer(); //DateFormat.getInstance() XYItemLabelGenerator generator = new StandardXYItemLabelGenerator("{1} \n {2}", new SimpleDateFormat("yyyy.MM.dd"), new DecimalFormat("0.00")); renderer.setSeriesItemLabelGenerator(0, generator);//setLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); plot.setBackgroundPaint(Color.WHITE); plot.setDomainCrosshairPaint(Color.GRAY); if (renderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer rend = (XYLineAndShapeRenderer) renderer; rend.setBaseShapesVisible(true); rend.setBaseShapesFilled(true); } plot.setRenderer(renderer); chart.setBackgroundPaint(Color.white); return chart; }
From source file:autohit.call.modules.SimpleHttpModule.java
/** * Post method. It will set the target address for the client, as well as * clearing any state./*from w w w . j a v a2 s . c o m*/ * * @param url * the Url path, not to include protocol, address, and port (ie. * "/goats/index.html"). * @param nv * set of name/value pairs for the post. it can be empty. * @return the data from the page as a String * @throws CallException */ private String post(String url, Hashtable nv) throws CallException { if (started == false) { throw buildException("Tried to post when a session wasn't started.", CallException.CODE_MODULE_FAULT); } String result = null; String name; Object value; // Construct our method. PostMethod method = new PostMethod(url); method.setFollowRedirects(true); method.setStrictMode(false); //build the rest of the method try { // Construct the headers Enumeration eNV = nv.keys(); while (eNV.hasMoreElements()) { name = (String) eNV.nextElement(); value = nv.get(name); if (value instanceof String) { // Only take it if it is a string method.addParameter(name, (String) value); debug("ADD POST - name=" + name + " value=" + (String) value); } } //DEBUG debug("DUMP POST-------------------------------"); debug(method.toString()); debug("DUMP POST-------------------------------"); // Do it debug("(post)post=" + url); httpClient.executeMethod(method); // Process result result = method.getResponseBodyAsString(); log("(post)" + method.getStatusLine().toString() + " size=" + result.length()); } catch (HttpException he) { // Bad but not fatal error("(post)Error on connect to url " + url + ". Error=" + he.getMessage()); } catch (IOException ioe) { // Fatal throw buildException("(post)Unable to connect. Session is invalid.", CallException.CODE_MODULE_FAULT, ioe); } catch (Exception ex) { // Fatal throw buildException("(post)Serious general error.", CallException.CODE_MODULE_FAULT, ex); } finally { try { method.releaseConnection(); method.recycle(); } catch (Exception e) { // Already FUBAR } } return result; }