private void assignPartOf(String parent, String child) { if (!StringUtils.isEmpty(child) && !StringUtils.isEmpty(parent)) { Util.addToSetMap(partOfs, child, parent); } }
private void buildParentsMap() { parentToChildren = new HashMap<String, Set<String>>(); for (String child : childToParents.keySet()) { Set<String> parents = childToParents.get(child); for (String parent : parents) { if (!StringUtils.isEmpty(child) && !StringUtils.isEmpty(parent)) { Util.addToSetMap(parentToChildren, parent, child); } } } }
private void setReverseReferences() { Map<String, Set<String>> partOfsCopy = new HashMap<String, Set<String>>(partOfs); for (Map.Entry<String, Set<String>> entry : partOfsCopy.entrySet()) { String oboTerm = entry.getKey(); Set<String> parents = new HashSet<String>(entry.getValue()); for (String parent : parents) { if (parent.equals(CHROMOSOME)) { continue; } if (!StringUtils.isEmpty(oboTerm) && !StringUtils.isEmpty(parent)) { Util.addToSetMap(reversePartOfs, parent, oboTerm); } } } }
/** * Parse all xref, some gene will have multiple id from same source * e.g. P2RX5 HGNC:8536|MIM:602836|Ensembl:ENSG00000083454|Ensembl:ENSG00000257950|HPRD:09110| * Vega:OTTHUMG00000090700|Vega:OTTHUMG00000169623 * * @param xrefs a "|" separated string * @return a map of xrefs */ private static Map<String, Set<String>> parseXrefs(String xrefs) { Map<String, Set<String>> xrefMap = new HashMap<String, Set<String>>(); for (String xref : xrefs.split("\\|")) { if (!xref.startsWith("-")) { String[] bits = xref.split(":", 2); Util.addToSetMap(xrefMap, bits[0], bits[1]); } } return xrefMap; } }
String parent = bits[1]; if (!StringUtils.isEmpty(parent) && !StringUtils.isEmpty(child)) { Util.addToSetMap(manyToMany, child, parent.trim());
private Map<String, Set<String>> removeRelationshipFromChildren(Map<String, Set<String>> map1, Map<String, Set<String>> map2, Map<String, Set<String>> invalidPartOfs, String parent, String collectionName) { Set<String> children = parentToChildren.get(parent); if (children == null) { return Collections.emptyMap(); } for (String child : children) { // this relationship is in config, so we can't delete // remove parent relationship instead if (isManyToMany(collectionName, child)) { if (!StringUtils.isEmpty(collectionName) && !StringUtils.isEmpty(parent)) { Util.addToSetMap(invalidPartOfs, parent, collectionName); } continue; } removeRelationship(map1, map2, child, collectionName); removeRelationshipFromChildren(map1, map2, invalidPartOfs, child, collectionName); } return invalidPartOfs; }
private void processAdditionalConverters(Attributes attrs) { String fullyQualifiedName = attrs.getValue("class-name"); String constraintPath = attrs.getValue("constraint-path"); String targetType = attrs.getValue("target-type"); String title = attrs.getValue("title"); String urlField = attrs.getValue("urlField"); ClassDescriptor typeCld = model.getClassDescriptorByName(targetType); if (typeCld == null) { LOG.warn("Invalid target type for additional converter: " + targetType); return; } try { new Path(model, constraintPath); } catch (PathException e) { LOG.warn("Can't add converter to bag-queries.xml, constraint-path '" + constraintPath + "' isn't in " + model.getName() + " model."); return; } Set<String> clds = new HashSet<String>(); clds.add(typeCld.getName()); for (ClassDescriptor cld : model.getAllSubs(typeCld)) { clds.add(cld.getName()); } AdditionalConverter additionalConverter = new AdditionalConverter(constraintPath, targetType, fullyQualifiedName, title, urlField); for (String nextCld : clds) { Util.addToSetMap(additionalConverters, TypeUtil.unqualifiedName(nextCld), additionalConverter); } }
private void processAdditionalConverters(Attributes attrs) { String fullyQualifiedName = attrs.getValue("class-name"); String constraintPath = attrs.getValue("constraint-path"); String targetType = attrs.getValue("target-type"); String title = attrs.getValue("title"); String urlField = attrs.getValue("urlField"); ClassDescriptor typeCld = model.getClassDescriptorByName(targetType); if (typeCld == null) { LOG.warn("Invalid target type for additional converter: " + targetType); return; } try { new Path(model, constraintPath); } catch (PathException e) { LOG.warn("Can't add converter to bag-queries.xml, constraint-path '" + constraintPath + "' isn't in " + model.getName() + " model."); return; } Set<String> clds = new HashSet<String>(); clds.add(typeCld.getName()); for (ClassDescriptor cld : model.getAllSubs(typeCld)) { clds.add(cld.getName()); } AdditionalConverter additionalConverter = new AdditionalConverter(constraintPath, targetType, fullyQualifiedName, title, urlField); for (String nextCld : clds) { Util.addToSetMap(additionalConverters, TypeUtil.unqualifiedName(nextCld), additionalConverter); } }
assignPartOf(parent, child); } else if ("is_a".equals(relationshipType) && r.direct) { Util.addToSetMap(childToParents, child, parent);