Example usage for java.util HashMap remove

List of usage examples for java.util HashMap remove

Introduction

In this page you can find the example usage for java.util HashMap remove.

Prototype

public V remove(Object key) 

Source Link

Document

Removes the mapping for the specified key from this map if present.

Usage

From source file:com.oneops.transistor.service.BomManagerImpl.java

protected void check4Secondary(CmsCI platform, List<CmsCIRelation> platformCloudRels, String nsPath) {
    //get manifest clouds and priority; what is intended
    Map<Long, Integer> intendedCloudpriority = platformCloudRels.stream().filter(cloudUtil::isCloudActive)
            .collect(toMap(CmsCIRelationBasic::getToCiId, this::getPriority, (i, j) -> i));
    //are there any secondary clouds for deployment
    long numberOfSecondaryClouds = intendedCloudpriority.entrySet().stream()
            .filter(entry -> (entry.getValue().equals(SECONDARY_CLOUD_STATUS))).count();
    if (numberOfSecondaryClouds == 0) {
        return;//from w  w  w  . java2s .  co  m
    }

    String finalNsPath = nsPath;
    //what is deployed currently.
    String entryPoint = getEntryPoint(platform);
    if (entryPoint == null) {
        //for platforms which dont have entry points, like schema.
        logger.info("Skipping secondary check , as entry point is absent for this " + nsPath + " platform ciId "
                + platform.getCiId());
        return;
    }

    Map<Long, Integer> existingCloudPriority = platformCloudRels.stream().map(CmsCIRelationBasic::getToCiId)
            .flatMap(cloudId -> cmProcessor
                    .getToCIRelationsByNs(cloudId, CmsConstants.DEPLOYED_TO, null, entryPoint, finalNsPath)
                    .stream())
            .collect(toMap(CmsCIRelationBasic::getToCiId, this::getPriority, (i, j) -> {
                return Math.max(i, j);
            }));

    HashMap<Long, Integer> computedCloudPriority = new HashMap<>(existingCloudPriority);
    computedCloudPriority.putAll(intendedCloudpriority);

    //Now, take  all offline clouds from
    Map<Long, Integer> offlineClouds = platformCloudRels.stream().filter(cloudUtil::isCloudOffline)
            .collect(toMap(CmsCIRelationBasic::getToCiId, this::getPriority, (i, j) -> i));
    if (!offlineClouds.isEmpty()) {
        offlineClouds.forEach((k, v) -> {
            if (computedCloudPriority.containsKey(k)) {
                computedCloudPriority.remove(k);
            }
        });
    }

    long count = computedCloudPriority.entrySet().stream()
            .filter(entry -> (entry.getValue().equals(CmsConstants.SECONDARY_CLOUD_STATUS))).count();
    if (computedCloudPriority.size() == count) {
        //throw transistor exception
        String message = "";
        String clouds = platformCloudRels.stream().filter(rel -> !cloudUtil.isCloudActive(rel))
                .filter(rel -> (getPriority(rel) == PRIMARY_CLOUD_STATUS)).map(rel -> rel.getToCi().getCiName())
                .collect(joining(","));

        if (StringUtils.isNotEmpty(clouds)) {
            message = String.format(
                    "The deployment will result in no instances in primary clouds for platform %s. Primary clouds <%s>  are not in active state for this platform.  ",
                    nsPath, clouds);
        } else {
            message = String.format(
                    "The deployment will result in no instances in primary clouds for platform %s. Please check the cloud priority of the clouds. .  ",
                    nsPath);
        }

        throw new TransistorException(TRANSISTOR_ALL_INSTANCES_SECONDARY, message);
    }
}

From source file:com.funambol.exchange.httptransport.HTTP_FBA_Authentication.java

void processSetCookies(HashMap<String, String> cookieJar, String cookies) {
    int start = 0;
    while (start < cookies.length()) {

        String acookie;//  ww  w  . j a v  a2 s  . c o m
        if (cookies.indexOf(";", start) != -1) {
            acookie = cookies.substring(start, cookies.indexOf(";", start));
        } else {
            acookie = cookies.substring(start);
        }

        if (acookie.indexOf("=") != -1) {
            String cookiename = acookie.substring(0, acookie.indexOf("="));
            cookiename = cookiename.trim();
            String cookieval = acookie.substring(acookie.indexOf("=") + 1, acookie.length());

            if (!("path".equals(cookiename) || "expires".equals(cookiename))) {

                if ("".equals(cookieval)) {
                    cookieJar.remove(cookiename);
                } else {
                    cookieJar.put(cookiename, cookieval);
                }

            }
        }
        start += acookie.length() + 1;
    }
}

From source file:org.onecmdb.ui.gwt.desktop.server.service.change.ReconciliationEngine.java

public IRfcResult delete(List<ChangeItem> items) {
    List<CiBean> localBeans = local.getCI(token);
    List<CiBean> baseBeans = base.getCI(token);

    HashMap<String, CiBean> localBeanMap = new HashMap<String, CiBean>();
    HashMap<String, CiBean> baseBeanMap = new HashMap<String, CiBean>();

    for (CiBean bean : localBeans) {
        localBeanMap.put(bean.getAlias(), bean);
        // Reset id on local bean.
        bean.setId(null);/*w  ww .  jav  a 2s  .  co m*/
    }
    for (CiBean bean : baseBeans) {
        baseBeanMap.put(bean.getAlias(), bean);
    }

    for (ChangeItem item : items) {
        Boolean b = item.get("include");
        if (b != null && !b.booleanValue()) {
            localBeanMap.remove(item.get("alias"));
            baseBeanMap.remove(item.get("alias"));
        }
    }
    IRfcResult result = remote.update(token, new CiBean[0], baseBeanMap.values().toArray(new CiBean[0]));

    return (result);
}

From source file:org.onecmdb.ui.gwt.desktop.server.service.change.ReconciliationEngine.java

public IRfcResult commit(List<ChangeItem> items) {
    List<CiBean> localBeans = local.getCI(token);
    List<CiBean> baseBeans = base.getCI(token);

    HashMap<String, CiBean> localBeanMap = new HashMap<String, CiBean>();
    HashMap<String, CiBean> baseBeanMap = new HashMap<String, CiBean>();

    for (CiBean bean : localBeans) {
        localBeanMap.put(bean.getAlias(), bean);
        // Reset id on local bean.
        bean.setId(null);//from   w  w  w.j  a va2 s .c  om
    }
    for (CiBean bean : baseBeans) {
        baseBeanMap.put(bean.getAlias(), bean);
    }

    for (ChangeItem item : items) {
        Boolean b = item.get("include");
        if (b != null && !b.booleanValue()) {
            localBeanMap.remove(item.get("alias"));
            baseBeanMap.remove(item.get("alias"));
        }
    }
    IRfcResult result = remote.update(token, localBeanMap.values().toArray(new CiBean[0]),
            baseBeanMap.values().toArray(new CiBean[0]));

    return (result);
}

From source file:org.apache.hadoop.hdfs.tools.offlineImageViewer.TestOfflineImageViewer.java

private void compareNamespaces(HashMap<String, FileStatus> written, HashMap<String, LsElements> fileOutput) {
    assertEquals("Should be the same number of files in both, plus one for root" + " in fileoutput",
            fileOutput.keySet().size(), written.keySet().size() + 1);
    Set<String> inFile = fileOutput.keySet();

    // For each line in the output file, verify that the namespace had a
    // filestatus counterpart 
    for (String path : inFile) {
        if (path.equals("/")) // root's not included in output from system call
            continue;

        assertTrue("Path in file (" + path + ") was written to fs", written.containsKey(path));

        compareFiles(written.get(path), fileOutput.get(path));

        written.remove(path);
    }/* ww w.j  av  a 2  s . c  om*/

    assertEquals("No more files were written to fs", 0, written.size());
}

From source file:org.paxle.core.filter.impl.FilterListener.java

private void handleFilter(ServiceReference reference, int eventType) {
    // the service ID of the registered filter
    Long serviceID = (Long) reference.getProperty(Constants.SERVICE_ID);
    if (serviceID == null) {
        this.logger.error("Unable to (un)register filter. No OSGi service-id found!");
        return;/* ww w  .j a  va2s .  c  o m*/
    }

    // the id's of the target queues
    String targetIDs[] = this.getTargetIDs(reference.getProperty(IFilter.PROP_FILTER_TARGET));

    if (eventType == ServiceEvent.REGISTERED) {
        int registrationCount = 0;

        // get a reference to the filter
        IFilter<?> filter = (IFilter<?>) this.context.getService(reference);

        // getting the filter PID
        String filterPID = (String) reference.getProperty(Constants.SERVICE_PID);
        if (filterPID == null) {
            // generating a PID
            filterPID = reference.getBundle().getSymbolicName() + "#" + filter.getClass().getName();
        }

        // extraction filter-target annotations
        final HashMap<String, FilterQueuePosition> annotProps = new HashMap<String, FilterQueuePosition>();
        final FilterTarget target = filter.getClass().getAnnotation(FilterTarget.class);
        if (target != null)
            for (final FilterQueuePosition pos : target.value())
                annotProps.put(pos.queueId(), pos);

        // adding the filter to multiple targets
        if (targetIDs != null) {
            for (String targetParamString : targetIDs) {
                final String[] params = targetParamString.split(";");

                /*
                 * Filter properties defined via annotation were overwritten via
                 * properties defined at service-registration time
                 */
                final FilterQueuePosition pos = annotProps.remove(params[0].trim());

                // register filter
                this.filterManager
                        .addFilter(this.generateFilterMetadata(filterPID, serviceID, params, filter, pos));
                registrationCount++;
            }
        }

        // adding the filter to all targets defined only via annotation
        final String[] params = new String[1];
        for (final FilterQueuePosition pos : annotProps.values()) {
            params[0] = pos.queueId(); // filter-queue ID

            this.filterManager
                    .addFilter(this.generateFilterMetadata(filterPID, serviceID, params, filter, pos));

            registrationCount++;
        }

        if (registrationCount == 0) {
            this.logger.warn(String.format(
                    "Filter '%s' with serviceID '%s' has neither defined an %s-annotation nor a %s-property. "
                            + "Skipping filter ...",
                    filter.getClass().getName(), serviceID.toString(), FilterTarget.class.getSimpleName(),
                    IFilter.PROP_FILTER_TARGET));
        } else {
            this.logger.info(String.format("Filter '%s' with serviceID '%s' registered.",
                    filter.getClass().getName(), serviceID.toString()));
        }
    } else if (eventType == ServiceEvent.UNREGISTERING) {
        if (targetIDs != null) {
            for (String targetID : targetIDs) {
                this.filterManager.removeFilter(serviceID, targetID);
            }
        } else {
            this.filterManager.removeFilter(serviceID);
        }
        this.logger.info(String.format("Filter with serviceID '%s' unregistered.", serviceID.toString()));
    } else if (eventType == ServiceEvent.MODIFIED) {
        // service properties have changed
    }
}

From source file:ece356.UserDBAO.java

public static ArrayList<DoctorData> queryDoctor(HashMap<String, String> doctorParam, String user)
        throws ClassNotFoundException, SQLException {
    Connection con = null;//from w  w w  .  jav a 2  s  .c  o m
    PreparedStatement pstmt = null;
    ArrayList<DoctorData> ret;
    try {
        con = getConnection();
        String query;
        boolean reviewByFriends = false;
        if (doctorParam.containsKey("reviewByFriends")) {

            if (doctorParam.get("reviewByFriends").equals("yes")) {

                query = "select * from doctorSearchView where username in (select username from doctorSearchView left join review on doctorSearchView.doc_spec_username = review.doc_username where doctorSearchView.patient_username in "
                        + "(select friend.sent_username as friend "
                        + "from friend where friend.isAccepted = 1 AND friend.recieved_username like '%" + user
                        + "%'" + "union " + "select friend.recieved_username as friend "
                        + "from friend where friend.isAccepted = 1 AND friend.sent_username like '%" + user
                        + "%'))";
                reviewByFriends = true;
            } else {
                query = "SELECT * FROM doctorSearchView ";
            }
            doctorParam.remove("reviewByFriends");
        } else {
            query = "SELECT * FROM doctorSearchView ";
            //pstmt = con.prepareStatement(query);

        }
        // Query for general doctor information
        ArrayList<String> keys = new ArrayList<String>(doctorParam.keySet());
        ArrayList<String> values = new ArrayList<String>(doctorParam.values());

        HashMap<Integer, Integer> h1 = new HashMap<>();
        int counter = 0;
        if (!keys.isEmpty()) {
            counter++;
            if (!reviewByFriends)
                query = query + " where";
            else
                query = query + " AND";

            for (String key : keys) {
                if (key.equals("averageRating") || key.equals("yearsLicensed")) {
                    query = query + " " + key + " >= ?";
                    query += " AND";
                    h1.put(counter, counter);
                } else if (key.equals("gender")) {
                    query = query + " " + key + " = ?";
                    query += " AND";
                    h1.put(counter, counter);
                } else if (keys.equals("reviewByFriends")) {

                } else {
                    query = query + " " + key + " LIKE ?";
                    query += " AND";
                }
                counter++;
            }
            query = query.substring(0, query.length() - 4);
            System.out.println(query);
        }

        query += " group by first_name, last_name, gender, averageRating, numberOfReviews";

        pstmt = con.prepareStatement(query);

        if (!values.isEmpty()) {
            counter = 1;
            for (String value : values) {
                if (h1.containsKey(counter)) {
                    pstmt.setString(counter, value);
                } else {
                    pstmt.setString(counter, "%" + value + "%");
                }
                counter++;
            }
        }
        System.out.println(pstmt);
        ResultSet resultSet;
        resultSet = pstmt.executeQuery();

        ret = new ArrayList();

        while (resultSet.next()) {
            DoctorData doctor = new DoctorData();
            doctor.userName = resultSet.getString("username");
            doctor.firstName = resultSet.getString("first_name");
            doctor.middleInitial = resultSet.getString("middle_initial");
            doctor.lastName = resultSet.getString("last_name");
            doctor.gender = resultSet.getString("gender");
            doctor.averageRating = resultSet.getDouble("averageRating");
            doctor.numberOfReviews = resultSet.getInt("numberOfReviews");
            ret.add(doctor);
        }
        return ret;
    } catch (Exception e) {
        System.out.println("EXCEPTION:%% " + e);
    } finally {
        if (pstmt != null) {
            pstmt.close();
        }
        if (con != null) {
            con.close();
        }
    }
    return null;
}

From source file:org.marketcetera.util.l10n.MessageComparator.java

/**
 * Creates a new comparator for the given meta-information. For
 * both parameters, the order of list elements is unimportant.
 *
 * @param srcInfo The source meta-information.
 * @param dstInfo The destination meta-information.
 *///from   w w  w .ja  v a2  s  .c  o m

public MessageComparator(List<MessageInfo> srcInfo, List<MessageInfo> dstInfo) {

    // Analyze source and destination.

    HashMap<String, MessageInfo> srcMessages = toHashMap(srcInfo);
    HashMap<String, MessageInfo> dstMessages = toHashMap(dstInfo);

    // Compare.

    LinkedList<MessageInfoPair> mismatches = new LinkedList<MessageInfoPair>();
    LinkedList<MessageInfo> extraSrcInfo = new LinkedList<MessageInfo>();
    for (String name : srcMessages.keySet()) {
        MessageInfo srcMessage = srcMessages.get(name);

        // Message missing from destination.

        if (!dstMessages.containsKey(name)) {
            extraSrcInfo.add(srcMessage);
            continue;
        }

        // Message exists in both source and destination, but
        // parameter count differs.

        MessageInfo dstMessage = dstMessages.get(name);
        if ((srcMessage.getParamCount() != -1) && (dstMessage.getParamCount() != -1)
                && (srcMessage.getParamCount() != dstMessage.getParamCount())) {
            mismatches.add(new MessageInfoPair(srcMessage, dstMessage));
        }
        dstMessages.remove(name);
    }

    // Retain results.

    mMismatches = mismatches.toArray(MessageInfoPair.EMPTY_ARRAY);
    mExtraSrcInfo = extraSrcInfo.toArray(MessageInfo.EMPTY_ARRAY);
    mExtraDstInfo = dstMessages.values().toArray(MessageInfo.EMPTY_ARRAY);
}

From source file:de.fuberlin.wiwiss.marbles.MarblesServlet.java

/**
 * Discovers an URI and renders a given view for it (<code>view</code>).
 *
 * @param request//  ww  w  . jav a 2s  .com
 * @param response
 * @throws IOException
 */
public void fresnelView(HttpServletRequest request, HttpServletResponse response) throws IOException {
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), "UTF-8"));
    String errorString = null;
    Selection selected = null;
    List<org.apache.commons.httpclient.URI> retrievedURLs = null;
    Resource focalResource = null;
    Configuration conf = null;
    String redirectLocation = null;

    try {
        /* Reload the Fresnel configuration using the provided language */
        String langPref = (request.getParameter("lang") != null ? request.getParameter("lang") : "en");
        loadFresnelConfig(langPref);

        conf = new Configuration(confRepository, ontoRepository);

        /* Create the focal resource */
        if (request.getParameter("uri") != null) {
            String uriString = request.getParameter("uri");
            if (uriString.startsWith("_:")) /* blank node */
                focalResource = valueFactory.createBNode(uriString.substring(2));
            else
                focalResource = valueFactory.createURI(uriString);

            /* Collect data about the focal resource */
            if (request.getParameter("skipload") == null) {
                retrievedURLs = semwebClient.discoverResource(focalResource, true /* wait */);
            } /* skip */

            /* Initiate manual owl:sameAs inference */
            if (request.getParameter("skipInference") == null) {
                sameAsInferencer.addInferredForResource(focalResource);
            }

            if (conf.hasWarnings())
                writer.println(conf.getWarningsString());

            Purpose purpose = null;

            /* Look up the requested lens purpose */
            if (request.getParameter("purpose") != null
                    && (!request.getParameter("purpose").equals("defaultPurpose")))
                purpose = new Purpose(new URIImpl(Constants.nsFresnelExt + request.getParameter("purpose")));
            else
                purpose = new Purpose(new URIImpl(
                        "http://www.w3.org/2004/09/fresnel#defaultLens")); /* this must be provided, or a random lens is chosen */

            try {
                /* Perform Fresnel selection using the requested display purpose and language */
                selected = conf.select(dataRepository, focalResource, purpose, langPref);

                /* Perform Fresnel formatting */
                selected = conf.format(dataRepository, selected);
            } catch (NoResultsException e) {

                /* 
                 * If no results are found, redirect the user to the resource
                 * if it is not an RDF document.
                 * This code is not reached when there already is some data about the resource.
                 */
                RepositoryConnection metaDataConn = null;
                try {
                    metaDataConn = metaDataRepository.getConnection();

                    /* Manual support for one level of redirects */
                    String resourceRedirect = cacheController.getCachedHeaderDataValue(metaDataConn,
                            focalResource, "location");
                    Resource resourceURI = (resourceRedirect == null ? focalResource
                            : new URIImpl(resourceRedirect));

                    /* Get target content type */
                    String contentType = cacheController.getCachedHeaderDataValue(metaDataConn, resourceURI,
                            "content-type");
                    if (contentType != null && !ContentTypes.isRDF(contentType)) {
                        redirectLocation = focalResource.toString();
                    }
                } catch (RepositoryException re) {
                    re.printStackTrace();
                } catch (IllegalArgumentException ie) {
                    ie.printStackTrace();
                } finally {
                    try {
                        if (metaDataConn != null)
                            metaDataConn.close();
                    } catch (RepositoryException re) {
                        re.printStackTrace();
                    }
                }
            }
        } /* uri != null */
    } catch (Exception e) {
        e.printStackTrace();
        errorString = e.getMessage();
    }

    /* Output */
    try {
        /* Handle redirection to non-RDF data */
        if (redirectLocation != null) {
            response.setHeader("Location", redirectLocation);
            response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
        } else { /* Perform XSL output */

            /*
             * When there are no results, we still need a selection object in 
             * order to render the fresnel tree
             */
            if (selected == null)
                selected = new Selection(conf);

            Document fresnelTree = selected.render();
            addSources(fresnelTree, retrievedURLs);

            /* Prepare XSLT */
            StreamSource styleSource = new StreamSource(
                    new File(dataRoot + "/" + xslDirectory + "/" + xslTransformation));
            net.sf.saxon.TransformerFactoryImpl tf = new net.sf.saxon.TransformerFactoryImpl();
            Transformer styleTransformer = tf.newTransformer(styleSource);

            /* Debug output */
            if (request.getParameter("debug") != null) {
                /* debug output: fresnel tree */
                StringWriter stringWriter = new StringWriter();
                Transformer treeTransformer = tf.newTransformer();
                treeTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
                treeTransformer.transform(new DOMSource(fresnelTree), new StreamResult(stringWriter));
                styleTransformer.setParameter("fresnelTree", stringWriter.getBuffer().toString());
            }

            /* Apply parameters */
            styleTransformer.setParameter("assetsURL", assetsURL != null ? assetsURL.toString() : "");
            styleTransformer.setParameter("serviceURL", serviceURL != null ? serviceURL.toString() : "");
            styleTransformer.setParameter("errorString", errorString);
            styleTransformer.setParameter("mainResource",
                    focalResource != null ? focalResource.toString() : "");
            if (request.getParameter("purpose") != null)
                styleTransformer.setParameter("purpose", request.getParameter("purpose"));
            else
                styleTransformer.setParameter("purpose", "defaultPurpose");

            if (request.getParameter("mobile") != null)
                styleTransformer.setParameter("isMobile", request.getParameter("mobile"));

            HashMap<String, String[]> newParameters = new HashMap<String, String[]>(request.getParameterMap());

            if (!newParameters.containsKey("lang"))
                newParameters.put("lang", new String[] { "en" });

            for (Object key : new String[] { "purpose", "uri" }) {
                newParameters.remove(key);
            }

            String parameterString = "";

            /* Serialize parameters for use in HTML links and forms */
            for (Object key : newParameters.keySet()) {
                parameterString += (parameterString.equals("") ? "" : "&") + key + "="
                        + ((String[]) newParameters.get(key))[0];
            }

            styleTransformer.setParameter("sessionParams", parameterString);

            /* Perform rendering */
            StreamResult res = new StreamResult(writer);
            styleTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
            styleTransformer.transform(new DOMSource(fresnelTree), res);
        }
    } catch (Exception e) {
        e.printStackTrace();
        writer.print(e.getMessage());
    } finally {
    }
}

From source file:ch.icclab.cyclops.resource.impl.TelemetryResource.java

/**
 * In this method, the usage metrics from the cumulative meters are extracted
 *
 * Pseudo Code/*from   w w  w  .  j  a v  a 2 s. co m*/
 * 1. Query the sample api of Telemetry
 * 2. Receive the ungrouped samples but already sorted for timestamp
 * 3. Group the sample on per resource basis
 * 4. Iterate through the array, add the subtracted value of two simultaneous samples at a time
 * 5. If the subtracted value is negative, adjust the value as per the datatype max limit
 * 6. Save all these details along with the usage in the db
 *
 * @param token The token generated by the keystone service is used for authorization by Telemetry Service
 * @return output A String output of the success or failure of the data extraction process
 * @throws JSONException
 * @throws IOException
 */
private boolean getCumulativeMeterData(ArrayList<String> meter, String token) {
    boolean output = false;
    String response = null;
    Set keySet;
    String meterType = "cumulative";
    CumulativeMeterData data = null;
    LinkedList<CumulativeMeterData> linkedList;
    JSONArray array = null;

    ObjectMapper mapper = new ObjectMapper();
    TelemetryClient tClient = new TelemetryClient();
    ArrayList<CumulativeMeterData> cMeterArr;
    TSDBResource dbResource = new TSDBResource();
    HashMap<String, LinkedList<CumulativeMeterData>> map;

    for (int j = 0; j < meter.size(); j++) {
        cMeterArr = new ArrayList<CumulativeMeterData>();
        map = new HashMap<String, LinkedList<CumulativeMeterData>>();
        try {
            response = tClient.getData(token, meter.get(j), meterType);
            array = new JSONArray(response);

            //Builds an array of samples and a hashmap of resourceID as key and a linkedlist of samples as values.
            for (int i = 0; i < array.length(); i++) {
                JSONObject obj = null;
                obj = array.getJSONObject(i);
                data = mapper.readValue(obj.toString(), CumulativeMeterData.class);

                if (map.containsKey(data.getResource_id())) {
                    linkedList = map.get(data.getResource_id());
                    linkedList.add(data);
                    map.remove(data.getResource_id());
                    map.put(data.getResource_id(), linkedList);
                } else {
                    linkedList = new LinkedList<CumulativeMeterData>();
                    linkedList.add(data);
                    map.put(data.getResource_id(), linkedList);
                }
            }

            //Get the Set of keys
            keySet = map.keySet();
            Iterator setIterator = keySet.iterator();

            //Iterate through the Set to extract the LinkedList
            while (setIterator.hasNext()) {
                linkedList = map.get(setIterator.next());
                cMeterArr = calculateCumulativeMeterUsage(cMeterArr, linkedList);
            }
            dbResource.saveCumulativeMeterData(cMeterArr, meter.get(j));
            output = true;
        } catch (IOException e) {
            output = false;
            e.printStackTrace();
            return output;
        } catch (JSONException e) {
            output = false;
            e.printStackTrace();
            return output;
        }
    }
    return output;
}