List of usage examples for java.util Hashtable put
public synchronized V put(K key, V value)
From source file:com.autentia.intra.manager.billing.BillManager.java
/** * Account DAO *//from w ww. j av a 2 s .co 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:com.stratuscom.harvester.deployer.FolderBasedAppRunner.java
private void unregisterApplication(ServiceLifeCycle deployedApp) { try {/*from ww w. java 2 s. com*/ Hashtable<String, String> props = new Hashtable<String, String>(); props.put(com.stratuscom.harvester.Strings.NAME, deployedApp.getName()); ObjectName oName = new ObjectName(com.stratuscom.harvester.Strings.CONTAINER_JMX_DOMAIN, props); mbeanRegistrar.getMbeanServer().unregisterMBean(oName); } catch (Exception e) { log.log(Level.SEVERE, MessageNames.FAILED_TO_REMOVE_MBEAN, new Object[] { deployedApp.getName() }); } }
From source file:com.openmeap.admin.web.AdminTestHelper.java
public HttpResponse getGlobalSettings() throws HttpRequestException { Hashtable<String, Object> getData = new Hashtable<String, Object>(); getData.put(FormConstants.PAGE_BEAN, FormConstants.PAGE_BEAN_GLOBAL_SETTINGS); return requestExecuter.get(adminUrl, getData); }
From source file:com.securekey.sdk.sample.rp.SampleRPSession.java
/** * Synchronous HTTP(S) request/response to RP Server * <p></p>//w w w. j ava2s . c o m * Sends request to RP Server, waits for response and sends response back to caller * * @param request payload (HTTP query parameters) * @return JSONObject as received from briidge.net by RP Server * */ private JSONObject sendMessageExpectJson(final String request) { String result = sendMessage(request); JSONObject resultJson = null; try { resultJson = new JSONObject(result); } catch (Exception e) { Hashtable<String, String> responseData = new Hashtable<String, String>(); responseData.put(STATUS_ERROR, "Network Error"); resultJson = new JSONObject(responseData); } return resultJson; }
From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.services.transformationmanager.services.FelixService.java
@Override public void onCreate() { super.onCreate(); if (D)//from w w w . jav a 2 s .com Log.d(TAG, "Setting up a thread for felix."); Thread felixThread = new Thread() { @Override public void run() { File dexOutputDir = getApplicationContext().getDir("transformationmanager", 0); // if default bundles were not installed already, install them File f = new File(dexOutputDir.getAbsolutePath() + "/bundle"); if (!f.isDirectory()) { if (D) Log.i(TAG, "Installing default bundles..."); unzipBundles(FelixService.this.getResources().openRawResource(R.raw.bundles), dexOutputDir.getAbsolutePath() + "/"); } FelixConfig felixConfig = new FelixConfig(dexOutputDir.getAbsolutePath()); Map<String, String> configProperties = felixConfig.getProperties2(); try { FrameworkFactory frameworkFactory = new org.apache.felix.framework.FrameworkFactory(); felixFramework = frameworkFactory.newFramework(configProperties); felixFramework.init(); AutoProcessor.process(configProperties, felixFramework.getBundleContext()); felixFramework.start(); // Registering the android context as an osgi service Hashtable<String, String> properties = new Hashtable<String, String>(); properties.put("platform", "android"); felixFramework.getBundleContext().registerService(Context.class.getName(), getApplicationContext(), properties); } catch (Exception ex) { Log.e(TAG, "Felix could not be started", ex); ex.printStackTrace(); } } }; felixThread.setDaemon(true); felixThread.start(); LocalBroadcastManager.getInstance(this).registerReceiver(downloadReceiver, new IntentFilter(FELIX_SUCCESSFUL_WEB_REQUEST)); }
From source file:com.openmeap.admin.web.AdminTestHelper.java
public HttpResponse postLogin(String userName, String password) throws HttpRequestException { Hashtable<String, Object> postData = new Hashtable<String, Object>(); postData.put("j_username", userName); postData.put("j_password", password); return requestExecuter.postData(adminUrl + "j_security_check", postData); }
From source file:com.openmeap.admin.web.AdminTestHelper.java
public HttpResponse getAddModifyAppVer(Application application) throws HttpRequestException { Hashtable<String, Object> getData = new Hashtable<String, Object>(); getData.put(FormConstants.PAGE_BEAN, FormConstants.PAGE_BEAN_APPVER_ADDMODIFY); getData.put(FormConstants.APP_ID, application.getPk().toString()); return requestExecuter.get(adminUrl, getData); }
From source file:com.openmeap.admin.web.AdminTestHelper.java
public HttpResponse getAddModifyAppPage(Application application) throws HttpRequestException { Hashtable<String, Object> getData = new Hashtable<String, Object>(); getData.put(FormConstants.PAGE_BEAN, FormConstants.PAGE_BEAN_APP_ADDMODIFY); if (application != null && application.getPk() != null) { getData.put(FormConstants.APP_ID, application.getPk().toString()); }//from w w w . j av a 2 s .c o m return requestExecuter.get(adminUrl, getData); }
From source file:io.fabric8.mq.controller.coordination.KubernetesControl.java
private BrokerOverview populateDestinations(J4pClient client, ObjectName root, BrokerDestinationOverviewImpl.Type type, BrokerOverview brokerOverview) { try {/*w w w . j ava2s . co m*/ Hashtable<String, String> props = root.getKeyPropertyList(); props.put("destinationType", type == BrokerDestinationOverviewImpl.Type.QUEUE ? "Queue" : "Topic"); props.put("destinationName", "*"); String objectName = root.getDomain() + ":" + Utils.getOrderedProperties(props); J4pResponse<J4pReadRequest> response = client .execute(new J4pReadRequest(objectName, "Name", "QueueSize", "ConsumerCount", "ProducerCount")); JSONObject value = response.getValue(); for (Object key : value.keySet()) { //get the destinations JSONObject jsonObject = (JSONObject) value.get(key); String name = jsonObject.get("Name").toString(); String producerCount = jsonObject.get("ProducerCount").toString().trim(); String consumerCount = jsonObject.get("ConsumerCount").toString().trim(); String queueSize = jsonObject.get("QueueSize").toString().trim(); if (!name.contains("Advisory") && !name.contains(ActiveMQDestination.TEMP_DESTINATION_NAME_PREFIX)) { ActiveMQDestination destination = type == BrokerDestinationOverviewImpl.Type.QUEUE ? new ActiveMQQueue(name) : new ActiveMQTopic(name); BrokerDestinationOverviewImpl brokerDestinationOverviewImpl = new BrokerDestinationOverviewImpl( destination); brokerDestinationOverviewImpl.setNumberOfConsumers(Integer.parseInt(consumerCount)); brokerDestinationOverviewImpl.setNumberOfProducers(Integer.parseInt(producerCount)); brokerDestinationOverviewImpl.setQueueDepth(Integer.parseInt(queueSize)); brokerOverview.addDestinationStatistics(brokerDestinationOverviewImpl); } } } catch (Exception ex) { // Destinations don't exist yet on the broker LOG.debug("populateDestinations failed", ex); } return brokerOverview; }
From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java
/** * Generate a stacked bar graph representing test execution time for each * product area. //from w ww . ja v a2s . c om * * @param builds List of builds * @param suites List of test suites * @param areas List of product areas * * @return Stacked bar chart representing test execution times across all builds */ public static final JFreeChart getAreaTestTimeChart(Vector<CMnDbBuildData> builds, Vector<CMnDbTestSuite> suites, Vector<CMnDbFeatureOwnerData> areas) { JFreeChart chart = null; // Collect the total times for each build, organized by area // This hashtable maps a build to the area/time information for that build Hashtable<Integer, Hashtable> buildTotals = new Hashtable<Integer, Hashtable>(); // Generate placeholders for each build so the chart maintains a // format consistent with the other charts that display build information HashSet areaNames = new HashSet(); if (builds != null) { Enumeration buildList = builds.elements(); while (buildList.hasMoreElements()) { CMnDbBuildData build = (CMnDbBuildData) buildList.nextElement(); // Create the empty area list buildTotals.put(new Integer(build.getId()), new Hashtable<String, Long>()); } } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if ((suites != null) && (suites.size() > 0)) { // Collect build test numbers for each of the builds in the list Enumeration suiteList = suites.elements(); while (suiteList.hasMoreElements()) { // Process the test summary for the current build CMnDbTestSuite suite = (CMnDbTestSuite) suiteList.nextElement(); Integer buildId = new Integer(suite.getParentId()); Long elapsedTime = new Long(suite.getElapsedTime()); // Parse the build information so we can track the time by build Hashtable<String, Long> areaTime = null; if (buildTotals.containsKey(buildId)) { areaTime = (Hashtable) buildTotals.get(buildId); } else { areaTime = new Hashtable<String, Long>(); buildTotals.put(buildId, areaTime); } // Iterate through each product area to determine who owns this suite CMnDbFeatureOwnerData area = null; Iterator iter = areas.iterator(); while (iter.hasNext()) { CMnDbFeatureOwnerData currentArea = (CMnDbFeatureOwnerData) iter.next(); if (currentArea.hasFeature(suite.getGroupName())) { area = currentArea; } } // Add the elapsed time for the current suite to the area total Long totalValue = null; String areaName = area.getDisplayName(); areaNames.add(areaName); if (areaTime.containsKey(areaName)) { Long oldTotal = (Long) areaTime.get(areaName); totalValue = oldTotal + elapsedTime; } else { totalValue = elapsedTime; } areaTime.put(areaName, totalValue); } // while list has elements // Populate the data set with the area times for each build Collections.sort(builds, new CMnBuildIdComparator()); Iterator buildIter = builds.iterator(); while (buildIter.hasNext()) { CMnDbBuildData build = (CMnDbBuildData) buildIter.next(); Integer buildId = new Integer(build.getId()); Hashtable areaTime = (Hashtable) buildTotals.get(buildId); Iterator areaKeys = areaNames.iterator(); while (areaKeys.hasNext()) { String area = (String) areaKeys.next(); Long time = (Long) areaTime.get(area); if (time != null) { // Convert the time from milliseconds to minutes time = time / (1000 * 60); } else { time = new Long(0); } dataset.addValue(time, area, buildId); } } } // if list has elements // API: ChartFactory.createStackedBarChart(title, domainAxisLabel, rangeAxisLabel, dataset, orientation, legend, tooltips, urls) chart = ChartFactory.createStackedBarChart("Automated Tests by Area", "Builds", "Execution Time (min)", dataset, PlotOrientation.VERTICAL, true, true, false); // get a reference to the plot for further customization... CategoryPlot plot = (CategoryPlot) chart.getPlot(); chartFormatter.formatAreaChart(plot, dataset); return chart; }