returns statements from supplied context

TBD - should share code path with above getStatements

@param subj
@param pred
@param obj
@param includeInferred
@param contexts
@throws RepositoryException
763276
@Override
    public RepositoryResult<Statement> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException {
        if (contexts == null) {
            contexts = new Resource[] { null };
        }
        try {
            if (isQuadMode()) {
                StringBuilder sb = new StringBuilder();
                sb.append("SELECT * WHERE { GRAPH ?ctx { ?s ?p ?o } filter (?ctx = (");
                boolean first = true;
                for (Resource context : contexts) {
                    if (first) {
                        first = !first;
                    }
                    else {
                        sb.append(",");
                    }
                    if (notNull(context)) {
                        sb.append("IRI(\"" + context.toString() + "\")");
                    } else {
                        sb.append("IRI(\""+DEFAULT_GRAPH_URI+"\")");
                    }
                }
                sb.append(") ) }");
                TupleQuery tupleQuery = prepareTupleQuery(sb.toString());
                tupleQuery.setIncludeInferred(includeInferred);
                setBindings(tupleQuery, subj, pred, obj, (Resource) null);
                TupleQueryResult qRes = tupleQuery.evaluate();
                return new RepositoryResult<Statement>(
                        new ExceptionConvertingIteration<Statement, RepositoryException>(
                                toStatementIteration(qRes, subj, pred, obj)) {
                            @Override
                            protected RepositoryException convert(Exception e) {
                                return new RepositoryException(e);
                            }
                        });
            } else if (subj != null && pred != null && obj != null) {
                if (hasStatement(subj, pred, obj, includeInferred, contexts)) {
                    Statement st = new StatementImpl(subj, pred, obj);
                    CloseableIteration<Statement, RepositoryException> cursor;
                    cursor = new SingletonIteration<Statement, RepositoryException>(st);
                    return new RepositoryResult<Statement>(cursor);
                } else {
                    return new RepositoryResult<Statement>(new EmptyIteration<Statement, RepositoryException>());
                }
            }
            else {
                MarkLogicGraphQuery query = prepareGraphQuery(EVERYTHING);
                setBindings(query, subj, pred, obj, contexts);
                GraphQueryResult result = query.evaluate();
                return new RepositoryResult<Statement>(
                        new ExceptionConvertingIteration<Statement, RepositoryException>(result) {
                            @Override
                            protected RepositoryException convert(Exception e) {
                                return new RepositoryException(e);
                            }
                        });
            }
        } catch (MalformedQueryException e) {
            throw new RepositoryException(e);
        } catch (QueryEvaluationException e) {
            throw new RepositoryException(e);
        }
    }
1325828
@Override
    public void export(RDFHandler handler, Resource... contexts) throws RepositoryException, RDFHandlerException {
        exportStatements(null, null, null, true, handler);
    }
317036
@Override
    protected void retrieveBundleContext() {

        BundleContext bc = TxBundleTools.getBundleContext();
        if (tc.isDebugEnabled())
            Tr.debug(tc, "retrieveBundleContext from TxBundleTools, bc " + bc);
        if (bc == null) {
            bc = EmbeddableTxBundleTools.getBundleContext();
            if (tc.isDebugEnabled())
                Tr.debug(tc, "retrieveBundleContext from EmbeddableTxBundleTools, bc " + bc);
        }
        _bc = bc;
    }
516102
public final BELScriptParser.statement_return statement() throws RecognitionException {
        BELScriptParser.statement_return retval = new BELScriptParser.statement_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token OPEN_PAREN50=null;
        Token CLOSE_PAREN54=null;
        Token STATEMENT_COMMENT56=null;
        BELScriptParser.outer_term_return outer_term48 = null;

        BELScriptParser.relationship_return relationship49 = null;

        BELScriptParser.outer_term_return outer_term51 = null;

        BELScriptParser.relationship_return relationship52 = null;

        BELScriptParser.outer_term_return outer_term53 = null;

        BELScriptParser.outer_term_return outer_term55 = null;


        Object OPEN_PAREN50_tree=null;
        Object CLOSE_PAREN54_tree=null;
        Object STATEMENT_COMMENT56_tree=null;

         paraphrases.push("in statement."); 
        try {
            // BELScript.g:135:5: ( outer_term ( relationship ( ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN ) | outer_term ) )? ( STATEMENT_COMMENT )? )
            // BELScript.g:136:5: outer_term ( relationship ( ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN ) | outer_term ) )? ( STATEMENT_COMMENT )?
            {
            root_0 = (Object)adaptor.nil();

            pushFollow(FOLLOW_outer_term_in_statement677);
            outer_term48=outer_term();

            state._fsp--;

            adaptor.addChild(root_0, outer_term48.getTree());
            // BELScript.g:136:16: ( relationship ( ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN ) | outer_term ) )?
            int alt9=2;
            int LA9_0 = input.LA(1);

            if ( ((LA9_0>=103 && LA9_0<=130)) ) {
                alt9=1;
            }
            switch (alt9) {
                case 1 :
                    // BELScript.g:136:17: relationship ( ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN ) | outer_term )
                    {
                    pushFollow(FOLLOW_relationship_in_statement680);
                    relationship49=relationship();

                    state._fsp--;

                    adaptor.addChild(root_0, relationship49.getTree());
                    // BELScript.g:136:30: ( ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN ) | outer_term )
                    int alt8=2;
                    int LA8_0 = input.LA(1);

                    if ( (LA8_0==OPEN_PAREN) ) {
                        alt8=1;
                    }
                    else if ( ((LA8_0>=44 && LA8_0<=102)) ) {
                        alt8=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 8, 0, input);

                        throw nvae;
                    }
                    switch (alt8) {
                        case 1 :
                            // BELScript.g:136:31: ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN )
                            {
                            // BELScript.g:136:31: ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN )
                            // BELScript.g:136:32: OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN
                            {
                            OPEN_PAREN50=(Token)match(input,OPEN_PAREN,FOLLOW_OPEN_PAREN_in_statement684); 
                            OPEN_PAREN50_tree = (Object)adaptor.create(OPEN_PAREN50);
                            adaptor.addChild(root_0, OPEN_PAREN50_tree);

                            pushFollow(FOLLOW_outer_term_in_statement686);
                            outer_term51=outer_term();

                            state._fsp--;

                            adaptor.addChild(root_0, outer_term51.getTree());
                            pushFollow(FOLLOW_relationship_in_statement688);
                            relationship52=relationship();

                            state._fsp--;

                            adaptor.addChild(root_0, relationship52.getTree());
                            pushFollow(FOLLOW_outer_term_in_statement690);
                            outer_term53=outer_term();

                            state._fsp--;

                            adaptor.addChild(root_0, outer_term53.getTree());
                            CLOSE_PAREN54=(Token)match(input,CLOSE_PAREN,FOLLOW_CLOSE_PAREN_in_statement692); 
                            CLOSE_PAREN54_tree = (Object)adaptor.create(CLOSE_PAREN54);
                            adaptor.addChild(root_0, CLOSE_PAREN54_tree);


                            }


                            }
                            break;
                        case 2 :
                            // BELScript.g:136:93: outer_term
                            {
                            pushFollow(FOLLOW_outer_term_in_statement697);
                            outer_term55=outer_term();

                            state._fsp--;

                            adaptor.addChild(root_0, outer_term55.getTree());

                            }
                            break;

                    }


                    }
                    break;

            }

            // BELScript.g:136:107: ( STATEMENT_COMMENT )?
            int alt10=2;
            int LA10_0 = input.LA(1);

            if ( (LA10_0==STATEMENT_COMMENT) ) {
                alt10=1;
            }
            switch (alt10) {
                case 1 :
                    // BELScript.g:136:107: STATEMENT_COMMENT
                    {
                    STATEMENT_COMMENT56=(Token)match(input,STATEMENT_COMMENT,FOLLOW_STATEMENT_COMMENT_in_statement702); 
                    STATEMENT_COMMENT56_tree = (Object)adaptor.create(STATEMENT_COMMENT56);
                    adaptor.addChild(root_0, STATEMENT_COMMENT56_tree);


                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

             paraphrases.pop(); 
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
1279106
@Override
    public void add(Statement st, Resource... contexts) throws RepositoryException {
        add(st.getSubject(), st.getPredicate(), st.getObject(), mergeResource(st.getContext(), contexts));
    }
628228
@Override
    public boolean hasStatement(Statement st, boolean includeInferred, Resource... contexts) throws RepositoryException {
        return hasStatement(st.getSubject(),st.getPredicate(),st.getObject(),includeInferred,contexts);
    }
646069
protected void checkReferenceable(ImportNodeData currentNodeInfo, String olUuid) throws RepositoryException
   {
      // if node is in version storage - do not assign new id from jcr:uuid
      // property
      if (Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3 <= currentNodeInfo.getQPath().getDepth()
         && currentNodeInfo.getQPath().getEntries()[Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3]
            .equals(Constants.JCR_FROZENNODE)
         && currentNodeInfo.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
      {
         return;
      }

      String identifier = validateUuidCollision(olUuid);

      if (identifier != null)
      {
         reloadChangesInfoAfterUC(currentNodeInfo, identifier);
      }
      else
      {
         currentNodeInfo.setIsNewIdentifer(true);
      }
      if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING)
      {
         NodeData parentNode = getParent();
         currentNodeInfo.setParentIdentifer(parentNode.getIdentifier());
         if (parentNode instanceof ImportNodeData && ((ImportNodeData)parentNode).isTemporary())
         {
            // remove the temporary parent
            tree.pop();
         }
      }
   }
232160
@Override
    public Collection<CodeReviewAuditResponse> getPeerReviewResponses(String repoUrl, String repoBranch, String scmName,
                                                                      long beginDt, long endDt) {
        Collector githubCollector = collectorRepository.findByName(!StringUtils.isEmpty(scmName) ? scmName : "GitHub");
        CollectorItem collectorItem = collectorItemRepository.findRepoByUrlAndBranch(githubCollector.getId(), repoUrl, repoBranch, true);

        // This is the list of repos in the database with the same repoUrl, but a different branch.
        List<CollectorItem> filteredCollectorItemList = new ArrayList<>();
        if ((collectorItem != null) && (collectorItem.isPushed())) {
            List<ObjectId> collectorIdList = new ArrayList<>();
            collectorIdList.add(githubCollector.getId());

            Iterable<CollectorItem> collectorItemIterable
                    = collectorItemRepository.findAllByOptionNameValueAndCollectorIdsIn(REPO_URL, repoUrl, collectorIdList);

            for (CollectorItem ci : collectorItemIterable) {
                if (repoBranch.equalsIgnoreCase((String) ci.getOptions().get(BRANCH))) { continue; }

                filteredCollectorItemList.add(ci);
            }

            return codeReviewEvaluatorLegacy.evaluate(collectorItem, filteredCollectorItemList, beginDt, endDt, null);
        }

        return codeReviewEvaluatorLegacy.evaluate(collectorItem, beginDt, endDt, null);
    }
658496
@Override
    public IQueryResult<T> fetch(IQueryContext context) {
        try {
            return QueryUtil.packageResult(processData(context, service.callRPC(rpcName, getArguments(context))));
        } catch (Exception e) {
            return QueryUtil.errorResult(e);
        }
    }
269883
private void validateIncomingReferences( JcrVersionNode version ) throws RepositoryException {
        for (PropertyIterator iter = version.getReferences(); iter.hasNext();) {
            AbstractJcrProperty prop = (AbstractJcrProperty)iter.next();
            AbstractJcrNode referrer = prop.getParent();

            // If the property's parent is the root node, fail.
            if (referrer.isRoot()) {
                throw new ReferentialIntegrityException(JcrI18n.cannotRemoveVersion.text(prop.getPath()));
            }
            boolean referrerIsAnotherVersion = (referrer instanceof JcrVersionNode)
                                               && ((JcrVersionNode)referrer).getContainingHistory()
                                                                            .getIdentifier()
                                                                            .equals(version.getContainingHistory()
                                                                                           .getIdentifier());
            if (!this.equals(referrer) && !referrerIsAnotherVersion) {
                throw new ReferentialIntegrityException(JcrI18n.cannotRemoveVersion.text(prop.getPath()));
            }
        }
    }
1023192
function(contextObj, options) {
        var context = this._parseContext(contextObj);
        var subKey = options.applySubstitutions !== false ? 'subbed': 'unsubbed';
        var collector = this.masterDelta ? [this.masterDelta[subKey]] : [];
        this._readNoMergeHelper(this.tree, 0, context, collector, subKey);
        return cloneDeep(collector);
    }
1353548
Type generateReturnConstraints(JCTree tree, Attr.ResultInfo resultInfo,
            MethodType mt, InferenceContext inferenceContext) {
        InferenceContext rsInfoInfContext = resultInfo.checkContext.inferenceContext();
        Type from = mt.getReturnType();
        if (mt.getReturnType().containsAny(inferenceContext.inferencevars) &&
                rsInfoInfContext != emptyContext) {
            from = types.capture(from);
            //add synthetic captured ivars
            for (Type t : from.getTypeArguments()) {
                if (t.hasTag(TYPEVAR) && ((TypeVar)t).isCaptured()) {
                    inferenceContext.addVar((TypeVar)t);
                }
            }
        }
        Type qtype = inferenceContext.asUndetVar(from);
        Type to = resultInfo.pt;

        if (qtype.hasTag(VOID)) {
            to = syms.voidType;
        } else if (to.hasTag(NONE)) {
            to = from.isPrimitive() ? from : syms.objectType;
        } else if (qtype.hasTag(UNDETVAR)) {
            if (resultInfo.pt.isReference()) {
                to = generateReturnConstraintsUndetVarToReference(
                        tree, (UndetVar)qtype, to, resultInfo, inferenceContext);
            } else {
                if (to.isPrimitive()) {
                    to = generateReturnConstraintsPrimitive(tree, (UndetVar)qtype, to,
                        resultInfo, inferenceContext);
                }
            }
        }
        Assert.check(allowGraphInference || !rsInfoInfContext.free(to),
                "legacy inference engine cannot handle constraints on both sides of a subtyping assertion");
        //we need to skip capture?
        Warner retWarn = new Warner();
        if (!resultInfo.checkContext.compatible(qtype, rsInfoInfContext.asUndetVar(to), retWarn) ||
                //unchecked conversion is not allowed in source 7 mode
                (!allowGraphInference && retWarn.hasLint(Lint.LintCategory.UNCHECKED))) {
            throw inferenceException
                    .setMessage("infer.no.conforming.instance.exists",
                    inferenceContext.restvars(), mt.getReturnType(), to);
        }
        return from;
    }
1036548
@Override
    public org.fcrepo.server.types.gen.RepositoryInfo describeRepository() {
        MessageContext ctx = context.getMessageContext();
        Context context = ReadOnlyContext.getSoapContext(ctx);
        assertInitialized();
        try {
            org.fcrepo.server.access.RepositoryInfo repositoryInfo =
                    m_access.describeRepository(context);
            org.fcrepo.server.types.gen.RepositoryInfo genRepositoryInfo =
                    TypeUtility
                            .convertReposInfoToGenReposInfo(repositoryInfo);
            return genRepositoryInfo;
        } catch (Throwable th) {
            LOG.error("Error describing repository", th);
            throw CXFUtility.getFault(th);
        }
    }
386828
void get_basic_features(final Context ctx,
                            final List<Integer> forms,
                            final List<Integer> postags,
                            final List<Integer> deprels,
                            List<Integer> features)
    {
        PUSH(features, FORM(forms, ctx.S0));
        PUSH(features, POSTAG(postags, ctx.S0));
        PUSH(features, FORM(forms, ctx.S1));
        PUSH(features, POSTAG(postags, ctx.S1));
        PUSH(features, FORM(forms, ctx.S2));
        PUSH(features, POSTAG(postags, ctx.S2));
        PUSH(features, FORM(forms, ctx.N0));
        PUSH(features, POSTAG(postags, ctx.N0));
        PUSH(features, FORM(forms, ctx.N1));
        PUSH(features, POSTAG(postags, ctx.N1));
        PUSH(features, FORM(forms, ctx.N2));
        PUSH(features, POSTAG(postags, ctx.N2));
        PUSH(features, FORM(forms, ctx.S0L));
        PUSH(features, POSTAG(postags, ctx.S0L));
        PUSH(features, DEPREL(deprels, ctx.S0L));
        PUSH(features, FORM(forms, ctx.S0R));
        PUSH(features, POSTAG(postags, ctx.S0R));
        PUSH(features, DEPREL(deprels, ctx.S0R));
        PUSH(features, FORM(forms, ctx.S0L2));
        PUSH(features, POSTAG(postags, ctx.S0L2));
        PUSH(features, DEPREL(deprels, ctx.S0L2));
        PUSH(features, FORM(forms, ctx.S0R2));
        PUSH(features, POSTAG(postags, ctx.S0R2));
        PUSH(features, DEPREL(deprels, ctx.S0R2));
        PUSH(features, FORM(forms, ctx.S0LL));
        PUSH(features, POSTAG(postags, ctx.S0LL));
        PUSH(features, DEPREL(deprels, ctx.S0LL));
        PUSH(features, FORM(forms, ctx.S0RR));
        PUSH(features, POSTAG(postags, ctx.S0RR));
        PUSH(features, DEPREL(deprels, ctx.S0RR));
        PUSH(features, FORM(forms, ctx.S1L));
        PUSH(features, POSTAG(postags, ctx.S1L));
        PUSH(features, DEPREL(deprels, ctx.S1L));
        PUSH(features, FORM(forms, ctx.S1R));
        PUSH(features, POSTAG(postags, ctx.S1R));
        PUSH(features, DEPREL(deprels, ctx.S1R));
        PUSH(features, FORM(forms, ctx.S1L2));
        PUSH(features, POSTAG(postags, ctx.S1L2));
        PUSH(features, DEPREL(deprels, ctx.S1L2));
        PUSH(features, FORM(forms, ctx.S1R2));
        PUSH(features, POSTAG(postags, ctx.S1R2));
        PUSH(features, DEPREL(deprels, ctx.S1R2));
        PUSH(features, FORM(forms, ctx.S1LL));
        PUSH(features, POSTAG(postags, ctx.S1LL));
        PUSH(features, DEPREL(deprels, ctx.S1LL));
        PUSH(features, FORM(forms, ctx.S1RR));
        PUSH(features, POSTAG(postags, ctx.S1RR));
        PUSH(features, DEPREL(deprels, ctx.S1RR));
    }
1259439
@Override
    public void add(Iterable<? extends Statement> statements, Resource... contexts) throws RepositoryException {
        Iterator <? extends Statement> iter = statements.iterator();
        while(iter.hasNext()){
            Statement st = iter.next();
            add(st, mergeResource(st.getContext(), contexts));
        }
    }
327192
public final void setContext(Kind c) {
        //NOTE:  Put context specific link code here.
        switch (c) {
            case ALL_CLASSES_FRAME:
            case PACKAGE_FRAME:
            case IMPLEMENTED_CLASSES:
            case SUBCLASSES:
            case METHOD_DOC_COPY:
            case FIELD_DOC_COPY:
            case PROPERTY_DOC_COPY:
            case CLASS_USE_HEADER:
                includeTypeInClassLinkLabel = false;
                break;

            case ANNOTATION:
                excludeTypeParameterLinks = true;
                excludeTypeBounds = true;
                break;

            case IMPLEMENTED_INTERFACES:
            case SUPER_INTERFACES:
            case SUBINTERFACES:
            case CLASS_TREE_PARENT:
            case TREE:
            case CLASS_SIGNATURE_PARENT_NAME:
                excludeTypeParameterLinks = true;
                excludeTypeBounds = true;
                includeTypeInClassLinkLabel = false;
                includeTypeAsSepLink = true;
                break;

            case PACKAGE:
            case CLASS_USE:
            case CLASS_HEADER:
            case CLASS_SIGNATURE:
                excludeTypeParameterLinks = true;
                includeTypeAsSepLink = true;
                includeTypeInClassLinkLabel = false;
                break;

            case MEMBER_TYPE_PARAMS:
                includeTypeAsSepLink = true;
                includeTypeInClassLinkLabel = false;
                break;

            case RETURN_TYPE:
            case SUMMARY_RETURN_TYPE:
                excludeTypeBounds = true;
                break;
            case EXECUTABLE_MEMBER_PARAM:
                excludeTypeBounds = true;
                break;
        }
        context = c;
        if (type != null &&
            type.asTypeVariable()!= null &&
            type.asTypeVariable().owner() instanceof ExecutableMemberDoc) {
            excludeTypeParameterLinks = true;
        }
    }
914097
public static String getContext(final PObject[] objs) {
        StringBuilder result = new StringBuilder("(");
        boolean first = true;
        for (PObject obj: objs) {
            if (!first) {
                result.append('|');
            }
            first = false;
            result.append(obj.getCurrentPath());
        }
        result.append(')');
        return result.toString();
    }