private boolean matchPullRequest(String base, String head, PullRequest openPR) { boolean matchingHead = head.equals(openPR.getHead().getLabel()); String openmrsBase = base.startsWith(OPENMRS_USER) ? base : OPENMRS_USER+":"+base; boolean matchingBase = openmrsBase.equals(openPR.getBase().getLabel()); return matchingBase && matchingHead; }
private Map<String, String> createPrMap(PullRequest request) { Map<String, String> params = new HashMap<String, String>(); if (request != null) { String title = request.getTitle(); if (title != null) params.put(PR_TITLE, title); String body = request.getBody(); if (body != null) params.put(PR_BODY, body); PullRequestMarker baseMarker = request.getBase(); if (baseMarker != null) { String base = baseMarker.getLabel(); if (base != null) params.put(PR_BASE, base); } PullRequestMarker headMarker = request.getHead(); if (headMarker != null) { String head = headMarker.getLabel(); if (head != null) params.put(PR_HEAD, head); } } return params; }
private Vertex savePullRequestMarker(final PullRequestMarker head) { Vertex markernode = getOrCreatePullRequestMarker(head); setProperty(markernode, PropertyName.LABEL, head.getLabel()); setProperty(markernode, PropertyName.SHA, head.getSha()); setProperty(markernode, PropertyName.REF, head.getRef()); User user = head.getUser(); if (user != null) { Vertex usernode = saveUser(user); createEdgeIfNotExist(markernode, usernode, EdgeType.PULLREQUESTMARKERUSER); } Repository repo = head.getRepo(); if (repo != null) { Vertex reponode = saveRepository(repo); createEdgeIfNotExist(markernode, reponode, EdgeType.REPOSITORY); } return markernode; }