Example usage for org.json.simple JSONObject keySet

List of usage examples for org.json.simple JSONObject keySet

Introduction

In this page you can find the example usage for org.json.simple JSONObject keySet.

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:JSONParser.JSONOperations.java

public JSONObject appendTwoJSONObjectsWithSameKeys(JSONObject moduleSummary, JSONObject moduleOwnerSumm) {

    Set<String> moduleCountkeys = moduleSummary.keySet();

    Set<String> moduleOwnerKeys = moduleOwnerSumm.keySet();
    for (Iterator moduleCountItr = moduleCountkeys.iterator(); moduleCountItr.hasNext();) {
        String owner = "--";
        String moduleCountName = (String) moduleCountItr.next();

        if (moduleOwnerKeys.contains(moduleCountName)) {
            owner = (String) moduleOwnerSumm.get(moduleCountName);
        }//from   w  ww . j a  v a  2  s .  c  o m
        JSONObject indiModuleJO = (JSONObject) moduleSummary.get(moduleCountName);
        indiModuleJO.put("Owner", owner);
        moduleSummary.put(moduleCountName, indiModuleJO);
    }

    return moduleSummary;

}

From source file:JSONParser.JSONOperations.java

public JSONObject mergeOwnerWithCount(JSONObject Mod_Count, JSONObject module_Owner) {
    JSONObject Mod_Count_Owner = new JSONObject();

    Set<String> Module_Owner_Keys = module_Owner.keySet();
    Set<String> Mod_Count_keys = Mod_Count.keySet();

    for (Iterator it = Mod_Count_keys.iterator(); it.hasNext();) {
        String moduleName = it.next().toString();
        System.out.println(moduleName);
        JSONObject moduleSummary = new JSONObject();
        Mod_Count_Owner.put(moduleName, moduleSummary);
        moduleSummary.put("moduleCount", Mod_Count.get(moduleName));

        String owner = "--";
        if (Module_Owner_Keys.contains(moduleName)) {
            owner = module_Owner.get(moduleName).toString();
        }//  w w  w .  j  a  v a  2  s . c o  m
        moduleSummary.put("moduleOwner", owner);

    }

    return Mod_Count_Owner;
}

From source file:ca.inverse.sogo.engine.source.SOGoUtilities.java

/**
        /*from  www .  j  ava 2s .  co  m*/
Sample output of c_settings :
        
 Calendar = {
 DragHandleVertical = 122;
 FolderColors = {
     "flachapelle:Calendar/personal" = "#FF6666";
     "lmarcotte:Calendar/2633-49F5AB80-1-ECD55D0" = "#CC33FF";
     "lmarcotte:Calendar/personal" = "#99FF99";
 };
 FolderShowAlarms = {
     "lmarcotte:Calendar/personal" = YES;
 };
 FolderShowTasks = {
     "lmarcotte:Calendar/personal" = YES;
 };
 FolderSyncTags = {
     "lmarcotte:Calendar/2633-49F5AB80-1-ECD55D0" = "a bb oo";
     "lmarcotte:Calendar/personal" = toto;
 };
 InactiveFolders = (
 );
 SubscribedFolders = (
     "flachapelle:Calendar/personal"
 );
 View = weekview;
  };
          
  As an example, for :
          
  FolderSyncTags = {
     "lmarcotte:Calendar/2633-49F5AB80-1-ECD55D0" = "a bb oo";
  };
        
  we'll eventually check, in sogo_folder_info:
          
  c_folder_type = 'Appointment' AND
  c_path2 = 'lmarcotte' AND
  c_path ENDS WITH 'Calendar/2633-49F5AB80-1-ECD55D0'
          
 */
public static HashMap getSyncTags(SOGoSyncSource source, int type, SyncContext context, String username,
        FunambolLogger log) {
    Vector<String> folders;
    HashMap h;

    h = new HashMap();

    // For now, we only support sync tags for calendars (events and tasks). So if we detect
    // a contact source, we return immediately.
    if (type == SOGoSyncSource.SOGO_CONTACT)
        return h;

    folders = new Vector<String>();

    try {
        ResultSet rs;
        Statement s;

        // We first fetch the user's time zone
        s = source.getDBConnection().createStatement();
        rs = s.executeQuery("SELECT c_settings FROM sogo_user_profile WHERE c_uid = '" + username + "'");

        if (rs.next()) {
            String data;

            data = rs.getString(1);

            // We've got no c_settings, return immediately
            if (data == null || data.length() == 0) {
                rs.close();
                s.close();
                return h;
            }

            try {
                JSONObject json, jsonCalendar;
                log.info("About to parse: " + data);
                json = (JSONObject) JSONValue.parse(data);

                if (json != null) {
                    jsonCalendar = (JSONObject) json.get("Calendar");

                    if (jsonCalendar != null) {
                        String key, value;
                        Iterator it;

                        json = (JSONObject) jsonCalendar.get("FolderSyncTags");
                        if (json != null) {
                            it = json.keySet().iterator();
                            while (it != null && it.hasNext()) {
                                key = it.next().toString();
                                value = (String) json.get(key);
                                h.put(value.toLowerCase(), key);
                            }
                        }

                        json = (JSONObject) jsonCalendar.get("FolderSynchronize");
                        if (json != null) {
                            it = json.keySet().iterator();
                            while (it != null && it.hasNext()) {
                                folders.add(it.next().toString());
                            }
                        }
                    }
                }
            } catch (Exception pe) {
                log.error("Exception occured in getSyncTags(): " + pe.toString(), pe);
            }
        }

        // We cleanup what we have to sync, if necessary. We only keep
        // the keys that are actually in "folders". 
        h.values().retainAll(folders);
        rs.close();
        s.close();

    } catch (Exception e) {
        log.error("Exception occured in getSyncTags(): " + e.toString(), e);
    }

    return h;
}

From source file:it.polimi.diceH2020.plugin.control.FileManager.java

private static boolean setMachineLearningHadoop(InstanceDataMultiProvider data) {
    // Set mapJobMLProfile - MACHINE LEARNING
    Map<String, JobMLProfile> jmlMap = new HashMap<String, JobMLProfile>();
    JSONParser parser = new JSONParser();

    try {//from w w  w .  j  av  a  2 s . co m
        for (ClassDesc cd : Configuration.getCurrent().getClasses()) {
            Map<String, SVRFeature> map = new HashMap<String, SVRFeature>();

            Object obj = parser.parse(new FileReader(cd.getMlPath()));
            JSONObject jsonObject = (JSONObject) obj;
            JSONObject parameter = (JSONObject) jsonObject.get("mlFeatures");

            Map<String, String> toCheck = cd.getAltDtsmHadoop()
                    .get(cd.getAltDtsmHadoop().keySet().iterator().next());
            for (String st : toCheck.keySet()) {
                if (!st.equals("file")) {
                    if (!parameter.containsKey(st)) {
                        JOptionPane.showMessageDialog(null, "Missing field in machine learning file: " + st
                                + "\n" + "for class: " + cd.getId(), "Error: ", JOptionPane.ERROR_MESSAGE);
                        return false;
                    }
                }
            }

            double b = (double) jsonObject.get("b");
            double mu_t = (double) jsonObject.get("mu_t");
            double sigma_t = (double) jsonObject.get("sigma_t");

            if (!parameter.containsKey("x")) {
                JOptionPane.showMessageDialog(null,
                        "Missing field in machine learning file: " + "x " + "\n" + "for class: " + cd.getId(),
                        "Error: ", JOptionPane.ERROR_MESSAGE);
                return false;
            }

            if (!parameter.containsKey("h")) {
                JOptionPane.showMessageDialog(null,
                        "Missing field in machine learning file: " + "h" + "\n" + "for class: " + cd.getId(),
                        "Error: ", JOptionPane.ERROR_MESSAGE);
                return false;
            }

            Iterator<?> iterator = parameter.keySet().iterator();
            while (iterator.hasNext()) {
                String key = (String) iterator.next();

                if (!toCheck.containsKey(key) && !key.equals("x") && !key.equals("h"))
                    continue;

                JSONObject locObj = (JSONObject) parameter.get(key);
                SVRFeature feat = new SVRFeature();
                feat.setMu((double) locObj.get("mu"));
                feat.setSigma((double) locObj.get("sigma"));
                feat.setW((double) locObj.get("w"));
                map.put(key, feat);
            }

            jmlMap.put(String.valueOf(cd.getId()), new JobMLProfile(map, b, mu_t, sigma_t));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    JobMLProfilesMap jML = JobMLProfilesMapGenerator.build();
    jML.setMapJobMLProfile(jmlMap);
    data.setMapJobMLProfiles(jML);

    return true;
}

From source file:com.ntua.cosmos.hackathonplanneraas.Planner.java

@Deprecated
private String getPOSTBody(JSONObject obj) {
    String body = "{}";
    StoredPaths pan = new StoredPaths();
    JSONObject returned = new JSONObject();
    ArrayList<String> names = new ArrayList<>();
    ArrayList<String> values = new ArrayList<>();
    String originalString = "";
    double similarity = 0.0, current = 0.0;
    if (!obj.isEmpty()) {
        Set keys = obj.keySet();
        Iterator iter = keys.iterator();
        for (; iter.hasNext();) {
            String temporary = String.valueOf(iter.next());
            if (temporary.startsWith("has"))
                names.add(temporary);//from  ww w  . j a  va 2  s  .  c o m
        }
        names.stream().forEach((name) -> {
            values.add(String.valueOf(obj.get(name)));
        });
    }
    originalString = values.stream().map((value) -> value).reduce(originalString, String::concat);
    //Begin the initialisation process.
    OntModelSpec s = new OntModelSpec(PelletReasonerFactory.THE_SPEC);
    //s.setReasoner(PelletReasonerFactory.theInstance().create());
    OntDocumentManager dm = OntDocumentManager.getInstance();
    dm.setFileManager(FileManager.get());
    s.setDocumentManager(dm);
    OntModel m = ModelFactory.createOntologyModel(s, null);
    //OntModel m = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
    InputStream in = FileManager.get().open(StoredPaths.casebasepath);
    if (in == null) {
        throw new IllegalArgumentException("File: " + StoredPaths.casebasepath + " not found");
    }
    // read the file
    m.read(in, null);
    //begin building query string.
    String queryString = pan.prefixrdf + pan.prefixowl + pan.prefixxsd + pan.prefixrdfs + pan.prefixCasePath;
    queryString += "\nSELECT DISTINCT ";
    for (int i = 0; i < names.size(); i++) {
        queryString += "?param" + i + " ";
    }
    queryString += "?message ?handle ?URI ?body WHERE {";
    for (int i = 0; i < names.size(); i++) {
        queryString += "?event base:" + names.get(i) + " ?param" + i + " . ";
    }
    queryString += "?event base:isSolvedBy ?solution . ?solution base:exposesMessage ?message . ?solution base:eventHandledBy ?handle . ?solution base:URI ?URI . ?solution base:hasPOSTBody ?body}";
    try {
        String testString = "";
        Query query = QueryFactory.create(queryString);
        //System.out.println(String.valueOf(query));
        QueryExecution qe = QueryExecutionFactory.create(query, m);
        ResultSet results = qe.execSelect();
        for (; results.hasNext();) {
            QuerySolution soln = results.nextSolution();
            // Access variables: soln.get("x");
            Literal lit;
            for (int i = 0; i < names.size(); i++) {
                lit = soln.getLiteral("param" + i);// Get a result variable by name.
                String temporary = String.valueOf(lit).substring(0, String.valueOf(lit).indexOf("^^"));
                testString += temporary;
            }
            String longer = testString, shorter = originalString;
            if (testString.length() < originalString.length()) { // longer should always have greater length
                longer = originalString;
                shorter = testString;
            }
            int longerLength = longer.length();
            current = (longerLength - StringUtils.getLevenshteinDistance(longer, shorter))
                    / (double) longerLength;
            if (similarity < current) {
                similarity = current;
                returned.clear();
                returned.put("message", soln.getLiteral("message").getString());
                returned.put("URI", soln.getLiteral("URI").getString());
                returned.put("handle", soln.getLiteral("handle").getString());
                body = soln.getLiteral("body").getString();
            }
        }
    } catch (Exception e) {
        System.out.println("Search is interrupted by an error.");
    }
    m.close();
    return body;
}

From source file:com.ntua.cosmos.hackathonplanneraas.Planner.java

@Deprecated
public JSONObject searchEventSolution(JSONObject obj) {
    StoredPaths pan = new StoredPaths();
    JSONObject returned = new JSONObject();
    long since = 0;
    long ts = 0;/*w  w w .j  ava 2 s .  c  o  m*/
    ArrayList<String> names = new ArrayList<>();
    ArrayList<String> values = new ArrayList<>();
    String originalString = "";
    double similarity = 0.0, current = 0.0;
    if (!obj.isEmpty()) {
        Set keys = obj.keySet();
        Iterator iter = keys.iterator();
        for (; iter.hasNext();) {
            String temporary = String.valueOf(iter.next());
            if (temporary.startsWith("has"))
                names.add(temporary);
        }

        names.stream().forEach((name) -> {
            values.add(String.valueOf(obj.get(name)));
        });
    }
    originalString = values.stream().map((value) -> value).reduce(originalString, String::concat);
    //Begin the initialisation process.
    OntModelSpec s = new OntModelSpec(PelletReasonerFactory.THE_SPEC);
    OntDocumentManager dm = OntDocumentManager.getInstance();
    dm.setFileManager(FileManager.get());
    s.setDocumentManager(dm);
    OntModel m = ModelFactory.createOntologyModel(s, null);
    InputStream in = FileManager.get().open(StoredPaths.casebasepath);
    if (in == null) {
        throw new IllegalArgumentException("File: " + StoredPaths.casebasepath + " not found");
    }
    // read the file
    m.read(in, null);
    //begin building query string.
    String queryString = pan.prefixrdf + pan.prefixowl + pan.prefixxsd + pan.prefixrdfs + pan.prefixCasePath;
    queryString += "\nSELECT DISTINCT ";
    for (int i = 0; i < names.size(); i++) {
        queryString += "?param" + i + " ";
    }
    queryString += "?message ?handle ?URI WHERE {";
    for (int i = 0; i < names.size(); i++) {
        queryString += "?event base:" + names.get(i) + " ?param" + i + " . ";
    }
    queryString += "?event base:isSolvedBy ?solution . ?solution base:exposesMessage ?message . ?solution base:eventHandledBy ?handle . ?solution base:URI ?URI}";
    try {
        String testString = "";
        Query query = QueryFactory.create(queryString);
        QueryExecution qe = QueryExecutionFactory.create(query, m);
        ResultSet results = qe.execSelect();
        for (; results.hasNext();) {
            QuerySolution soln = results.nextSolution();
            // Access variables: soln.get("x");
            Literal lit;
            for (int i = 0; i < names.size(); i++) {
                lit = soln.getLiteral("param" + i);// Get a result variable by name.
                String temporary = String.valueOf(lit).substring(0, String.valueOf(lit).indexOf("^^"));
                testString += temporary;
            }
            String longer = testString, shorter = originalString;
            if (testString.length() < originalString.length()) { // longer should always have greater length
                longer = originalString;
                shorter = testString;
            }
            int longerLength = longer.length();
            System.out.println("Similarity between:" + originalString + " and " + testString + " is:");
            current = (longerLength - StringUtils.getLevenshteinDistance(longer, shorter))
                    / (double) longerLength;
            System.out.println(current + " out of 1.0.");
            if (similarity < current) {
                similarity = current;
                returned.clear();
                returned.put("message", soln.getLiteral("message").getString());
                returned.put("URI", soln.getLiteral("URI").getString());
                returned.put("handle", soln.getLiteral("handle").getString());
            }
        }
    } catch (Exception e) {
        System.out.println("Search is interrupted by an error.");
    }
    m.close();
    return returned;
}

From source file:importer.handler.post.stages.Discriminator.java

Discriminator(JSONObject config) throws ConfigException {
    ArrayList sets = (ArrayList) config.get(REMOVALS);
    removals = new HashSet<String>();
    if (sets != null) {
        for (int i = 0; i < sets.size(); i++) {
            String r = (String) sets.get(i);
            removals.add(r);//  w ww. java 2  s  .com
        }
    }
    ArrayList brothers = (ArrayList) config.get(SIBLINGS);
    if (brothers == null)
        throw new ConfigException("missing siblings in splitter config");
    siblings = new HashMap<String, Sibling>();
    for (int i = 0; i < brothers.size(); i++) {
        JSONObject doc = (JSONObject) brothers.get(i);
        String first = (String) doc.get(FIRST);
        String second = (String) doc.get(SECOND);
        String wits = (String) doc.get(WITS);
        if (first != null && second != null) {
            siblings.put(first, new Sibling(first, second, wits));
            siblings.put(second, new Sibling(second, first, wits));
        }
    }
    ArrayList droplist = (ArrayList) config.get(DROPS);
    if (droplist == null)
        throw new ConfigException("missing droplist in splitter config");
    drops = new String[droplist.size()];
    for (int i = 0; i < droplist.size(); i++) {
        drops[i] = (String) droplist.get(i);
    }
    wits = (String) config.get(WITS);
    if (wits == null)
        wits = "wits";
    ArrayList keylist = (ArrayList) config.get(KEYS);
    if (keylist == null)
        throw new ConfigException("missing keylist in splitter config");
    for (int i = 0; i < keylist.size(); i++) {
        JSONObject doc = (JSONObject) keylist.get(i);
        Set keys = doc.keySet();
        Iterator iter = keys.iterator();
        while (iter.hasNext()) {
            String key = (String) iter.next();
            if (key.equals(ADD))
                add = (String) doc.get(key);
            else if (key.equals(DEL))
                del = (String) doc.get(key);
            else if (key.equals(REG))
                reg = (String) doc.get(key);
            else if (key.equals(CORR))
                corr = (String) doc.get(key);
            else if (key.equals(EXPAN))
                expan = (String) doc.get(key);
            else
                throw new ConfigException("Unknown key " + key);
        }
    }
}

From source file:JSONParser.JSONOperations.java

public JSONArray SupJOToReportsJA(JSONObject JSONObjectToParse, JSONObject extraColumns,
        JSONObject SupTorepColumnChngHeader, String rowName) {
    try {//from  ww w. j a  va 2 s.co m
        JSONArray issueMgrArray = new JSONArray();

        JSONArray row = getRowsFromSupportapiJSON(JSONObjectToParse, rowName);

        Iterator<JSONObject> iterator = row.iterator();
        while (iterator.hasNext()) {
            JSONObject issueMgrObj = new JSONObject();
            JSONArray rowIndex = (JSONArray) iterator.next().get("fl");
            Iterator<JSONObject> innerIterator = rowIndex.iterator();

            if (extraColumns != null) {

                Set<String> extraColumnKeys = extraColumns.keySet();

                for (Iterator it = extraColumnKeys.iterator(); it.hasNext();) {
                    String key = it.next().toString();
                    issueMgrObj.put(key, extraColumns.get(key));
                }
            }

            //issueMgrObj.put("Products", "Mobile Device Management (MDM)");
            while (innerIterator.hasNext()) {

                JSONObject field = innerIterator.next();
                Object columnHeader = field.get("val");
                Object columnValue = field.get("content");
                String setEmptyContent = "Not assigned";
                if (SupTorepColumnChngHeader != null) {
                    Set<String> suppHeaderChngKeySet = SupTorepColumnChngHeader.keySet();

                    for (Iterator itChange = suppHeaderChngKeySet.iterator(); itChange.hasNext();) {
                        String suppHeaderChngKeys = itChange.next().toString();

                        if (columnHeader.toString().equals(suppHeaderChngKeys)) {
                            if (columnValue != null) {
                                if (columnValue.equals("null")) {
                                    issueMgrObj.put(SupTorepColumnChngHeader.get(suppHeaderChngKeys),
                                            setEmptyContent);
                                } else {
                                    issueMgrObj.put(SupTorepColumnChngHeader.get(suppHeaderChngKeys),
                                            columnValue);
                                }
                            } else {
                                issueMgrObj.put(SupTorepColumnChngHeader.get(suppHeaderChngKeys),
                                        setEmptyContent);
                                loggerObj.log(Level.INFO,
                                        "Column value is null for the column header: " + columnHeader);
                            }
                        } else {
                            if (columnValue != null) {
                                if (columnValue.equals("null")) {
                                    issueMgrObj.put(columnHeader, setEmptyContent);
                                } else {
                                    issueMgrObj.put(columnHeader, columnValue);
                                }
                            } else {
                                issueMgrObj.put(columnHeader, setEmptyContent);
                            }
                        }
                    }
                } else {
                    if (columnValue != null) {
                        issueMgrObj.put(columnHeader, columnValue);
                    } else {
                        issueMgrObj.put(columnHeader, setEmptyContent);
                    }
                }

            }
            issueMgrArray.add(issueMgrObj);
        }

        loggerObj.log(Level.INFO, "Successfully parsed the support api data to reports api format");
        //JSONObject result = new JSONObject();
        //result.put("result", issueMgrArray);
        return issueMgrArray;

    } catch (Exception e) {
        loggerObj.log(Level.SEVERE, "Issue in parsing the support api data to reports api format", e);
        System.out.println("Issue in parsing the support api data to reports api format" + e.toString());
        return null;
    }
}

From source file:com.caspida.plugins.graph.EntityGraphNeo4jPlugin.java

/**
 * Nodes and edges are merged in two different API calls because node creation
 * returns the nodes hashes to nodeId map
 *
 * Adding nodeId to the edge request speeds up the process of edge creation
 * because the lookUp of nodes by nodeId is much faster then going with the index
 *
 * {/*w w  w.j a v a 2  s .  com*/
 *   containers : [
 *     {
 *       "labels" : ["a", "b"],
 *       "header" : [<Array of properties names. All edge rels array will
 *                   follow the same order>]
 *       "relmap" : {
 *         "hash1" : {
 *           "id" : <e1>,
 *           "rels" : [
 *             [<hash2>, <e2>, <relationship>, <conditional probability>,
 *             <joint probability>, <mutual information>]
 *           ],
 *         }
 *         ...
 *       }
 *     }
 *   ]
 * }
 * @param graphDb
 * @param json
 * @return
 */
@Name(EntityGraphConstants.API_MERGE_ENTITY_EDGES)
@Description("Merge entity edges")
@PluginTarget(GraphDatabaseService.class)
public String mergeBehaviorGraphEdges(@Source GraphDatabaseService graphDb,
        @Description("") @Parameter(name = "data", optional = true) String json) {

    // Perform request validations
    if ((json == null) || (json.trim().isEmpty())) {
        throw new IllegalArgumentException("Invalid JSON provided for method : " + json);
    }

    logger.debug("Merge edges request data : {}", json);
    JSONObject relIds = new JSONObject();
    long numEdges = 0;
    JSONObject response = new JSONObject();
    try {
        JSONParser parser = new JSONParser();
        JSONObject request = (JSONObject) parser.parse(json);

        JSONArray header = (JSONArray) request.get(EntityGraphConstants.REQ_PROPERTY_HEADER_TAG);

        JSONObject relationsMap = (JSONObject) request
                .get(EntityGraphConstants.REQ_EDGE_MERGE_RELATIONSHIP_MAP_TAG);
        Map<Long, Map<String, Relationship>> eventRelationships = new HashMap<>();

        for (Object key : relationsMap.keySet()) {
            eventRelationships.clear();
            String eventHash = key.toString();
            JSONObject data = (JSONObject) relationsMap.get(key);
            Long eventId = null;

            Node e1 = null;
            if ((eventId == null) || (eventId < 0)) {
                e1 = UniqueEntityFactory.getOrCreateNode(graphDb, eventHash, null);
            } else {
                try (Transaction txn = graphDb.beginTx()) {
                    e1 = graphDb.getNodeById(eventId);
                }
            }

            List<UniqueEntityFactory.RelationshipRequestInfo> requestInfoList = new ArrayList<>();
            JSONArray relationships = (JSONArray) data
                    .get(EntityGraphConstants.REQ_EDGE_MERGE_RELATIONSHIPS_TAG);
            for (Object objectRel : relationships) {
                JSONArray rel = (JSONArray) objectRel;
                Map<String, Object> edgeProperties = getPropertiesFromHeaderAndArray(header, rel);
                Object tmp;
                tmp = edgeProperties.remove(EntityGraphConstants.REQ_EDGE_MERGE_END_NODE_HASH_TAG);
                String endNodeEventHash = (tmp != null) ? tmp.toString() : null;

                Long endNodeEventId = null;
                tmp = edgeProperties.remove(EntityGraphConstants.REQ_EDGE_MERGE_END_DB_ID_TAG);
                String relEventIdObj = (tmp != null) ? tmp.toString() : null;

                try {
                    endNodeEventId = (relEventIdObj != null) ? Long.parseLong(relEventIdObj.toString()) : null;
                } catch (NumberFormatException e) {
                    // ignore exception and do a lookup
                }

                tmp = edgeProperties.remove(EntityGraphConstants.REQ_EDGE_PROPS_RELNAME_KEY);
                String relationshipName = (tmp != null) ? tmp.toString() : null;

                requestInfoList.add(new UniqueEntityFactory.RelationshipRequestInfo(e1, endNodeEventId,
                        endNodeEventHash, relationshipName, edgeProperties));
            }

            UniqueEntityFactory.createBulkRelationships(graphDb, e1, requestInfoList);
            for (UniqueEntityFactory.RelationshipRequestInfo rri : requestInfoList) {
                String relKey = rri.getDescr();
                Relationship relationship = rri.getRelationship();
                if ((relKey == null) || (relationship == null)) {
                    continue;
                }

                relIds.put(relKey, relationship.getId());
            }
            numEdges += requestInfoList.size();
        }

        response.put(EntityGraphConstants.RES_IDS_TAG, relIds);
    } catch (Throwable e) {
        logger.error("Failed to create entity graph : " + json, e);
        createErrorResponse(response, EntityGraphConstants.API_MERGE_ENTITY_EDGES,
                "Failed to merge entity graph", e);
    }

    return response.toJSONString();
}

From source file:main.MainClass.java

private String[] createMsgContentForMod_Count_Owner(JSONObject statusModuleSumm) {
    String[] result = new String[2];
    String content = "<HTML><BODY>";

    Set<String> statusKeys = statusModuleSumm.keySet();

    for (Iterator statusItr = statusKeys.iterator(); statusItr.hasNext();) {
        String status = (String) statusItr.next();
        content += "<h2>" + status + "</h2>";
        JSONObject moduleSummary = (JSONObject) statusModuleSumm.get(status);
        String moduleCountOwners = MEMDM_Mod_Count_OwnerJSONToHTML(moduleSummary);
        if (moduleCountOwners == null || moduleCountOwners.equals("")) {
            moduleCountOwners = "No data available";
        }// w  w  w .ja  v  a 2 s.  co m

        content += "<table border=\"1\" cellpadding=\"7\" rules=\"all\" frame=\"box\" style=\"width: 100%;\">\n"
                + "   <tbody>\n" + "      <tr>\n"
                + "         <td valign=\"top\" style=\"width: 33%; text-align: left; vertical-align: top; background-color: rgb(102, 255, 0);\"><b>Module</b></td>\n"
                + "         <td valign=\"top\" style=\"width: 33%; text-align: left; vertical-align: top; background-color: rgb(102, 255, 0);\"><b>Open Count</b></td>\n"
                + "         <td valign=\"top\" style=\"width: 33%; text-align: left; vertical-align: top; background-color: rgb(102, 255, 0);\"><b>Owner</b></td>\n"
                + "      </tr>\n" + moduleCountOwners + "   </tbody>\n" + "</table>\n";
    }

    /*content += "<htmml><body><table border=\"1\" cellpadding=\"7\" rules=\"all\" frame=\"box\" style=\"width: 100%;\">\n"
     + "   <tbody>\n"
     + "      <tr>\n"
     + "         <td valign=\"top\" style=\"width: 33%; text-align: left; vertical-align: top; background-color: rgb(102, 255, 0);\"><b>Module</b></td>\n"
     + "         <td valign=\"top\" style=\"width: 33%; text-align: left; vertical-align: top; background-color: rgb(102, 255, 0);\"><b>Open Count</b></td>\n"
     + "         <td valign=\"top\" style=\"width: 33%; text-align: left; vertical-align: top; background-color: rgb(102, 255, 0);\"><b>Owner</b></td>\n"
     + "      </tr>\n"
     + Module_Count_Owners
     + "   </tbody>\n"
     + "</table>\n"
     + "<br></body></html>";*/
    content += "</BODY></HTML>";
    String type = "text/html";
    //String writeResponseAsHTML = "./Files/MEMDMFiles/email_content" + getCurrTimeInDD_MM_YY_HH_MM_SS() + ".html";
    //FileOperations.writeObjectToFile(content, writeResponseAsHTML);
    result[0] = content;
    result[1] = type;
    return result;
}