/* * Gets a specific tag tuple from the database as specified by the tags ID. */ public RESTTopicV1 getTopicById( final int id, final Integer rev, final boolean expandTranslations) { try { final RESTTopicV1 topic; if (entityCache.containsKeyValue(RESTTopicV1.class, id, rev)) { topic = entityCache.get(RESTTopicV1.class, id, rev); } else { /* We need to expand the all the items in the topic collection */ final ExpandDataTrunk expand = new ExpandDataTrunk(); final ExpandDataTrunk expandTags = new ExpandDataTrunk(new ExpandDataDetails("tags")); final ExpandDataTrunk expandTopicTranslations = new ExpandDataTrunk(new ExpandDataDetails(RESTTopicV1.TRANSLATEDTOPICS_NAME)); expandTags.setBranches( CollectionUtilities.toArrayList( new ExpandDataTrunk(new ExpandDataDetails("categories")), new ExpandDataTrunk(new ExpandDataDetails("properties")))); expand.setBranches( CollectionUtilities.toArrayList( expandTags, new ExpandDataTrunk(new ExpandDataDetails("sourceUrls")), new ExpandDataTrunk(new ExpandDataDetails("properties")), new ExpandDataTrunk(new ExpandDataDetails("outgoingRelationships")), new ExpandDataTrunk(new ExpandDataDetails("incomingRelationships")))); if (expandTranslations) { expand.getBranches().add(expandTopicTranslations); } final String expandString = mapper.writeValueAsString(expand); // final String expandEncodedString = URLEncoder.encode(expandString, "UTF-8"); if (rev == null) { topic = client.getJSONTopic(id, expandString); entityCache.add(topic); } else { topic = client.getJSONTopicRevision(id, rev, expandString); entityCache.add(topic, true); } } return topic; } catch (Exception e) { log.error(ExceptionUtilities.getStackTrace(e)); } return null; }