@Test public void testBulkImportUtilInputs() throws IOException, FHIRException { FHIRRequestContext.set(new FHIRRequestContext("default")); assertFalse(BulkDataImportUtil.retrieveInputs(loadTestFile("/testdata/import/import-demo.json")).isEmpty()); assertEquals(BulkDataImportUtil.retrieveInputs(loadTestFile("/testdata/import/import-demo.json")).size(), 2); }
public static List<Input> retrieveInputs(Parameters parameters) throws FHIROperationException { List<Input> inputs = new ArrayList<>(); FHIRPathEvaluator evaluator = FHIRPathEvaluator.evaluator(); EvaluationContext evaluationContext = new EvaluationContext(parameters); try { Collection<FHIRPathNode> result = evaluator.evaluate(evaluationContext, "parameter.where(name = 'input')"); Iterator<FHIRPathNode> iter = result.iterator(); while (iter.hasNext()) { FHIRPathElementNode node = (FHIRPathElementNode) iter.next(); EvaluationContext evaluationContextPartType = new EvaluationContext(node.element()); Collection<FHIRPathNode> resultPartType = evaluator.evaluate(evaluationContextPartType, "part.where(name = 'type').value"); String type = ((FHIRPathElementNode) resultPartType.iterator().next()).element() .as(com.ibm.fhir.model.type.String.class).getValue(); if (!ModelSupport.isResourceType(type)) { throw buildExceptionWithIssue("$import invalid Resource Type 'input'", IssueType.INVALID); } EvaluationContext evaluationContextPartUrl = new EvaluationContext(node.element()); Collection<FHIRPathNode> resultPartUrl = evaluator.evaluate(evaluationContextPartUrl, "part.where(name = 'url').value"); String url = ((FHIRPathElementNode) resultPartUrl.iterator().next()).element() .as(com.ibm.fhir.model.type.Url.class).getValue(); verifyUrlAllowed(url); inputs.add(new Input(type, url)); } } catch (FHIRPathException e) { throw buildExceptionWithIssue("$import invalid parameters with expression in 'input'", e, IssueType.INVALID); } if (inputs.isEmpty()) { throw buildExceptionWithIssue("$import requires 'input' is not found", IssueType.INVALID); } checkAllowedTotalSizeForTenantOrSystem(inputs.size()); return inputs; }
BulkDataImportUtil { public static List<Input> retrieveInputs(Parameters parameters) throws FHIROperationException { List<Input> inputs = new ArrayList<>(); FHIRPathEvaluator evaluator = FHIRPathEvaluator.evaluator(); EvaluationContext evaluationContext = new EvaluationContext(parameters); try { Collection<FHIRPathNode> result = evaluator.evaluate(evaluationContext, "parameter.where(name = 'input')"); Iterator<FHIRPathNode> iter = result.iterator(); while (iter.hasNext()) { FHIRPathElementNode node = (FHIRPathElementNode) iter.next(); EvaluationContext evaluationContextPartType = new EvaluationContext(node.element()); Collection<FHIRPathNode> resultPartType = evaluator.evaluate(evaluationContextPartType, "part.where(name = 'type').value"); String type = ((FHIRPathElementNode) resultPartType.iterator().next()).element() .as(com.ibm.fhir.model.type.String.class).getValue(); if (!ModelSupport.isResourceType(type)) { throw buildExceptionWithIssue("$import invalid Resource Type 'input'", IssueType.INVALID); } EvaluationContext evaluationContextPartUrl = new EvaluationContext(node.element()); Collection<FHIRPathNode> resultPartUrl = evaluator.evaluate(evaluationContextPartUrl, "part.where(name = 'url').value"); String url = ((FHIRPathElementNode) resultPartUrl.iterator().next()).element() .as(com.ibm.fhir.model.type.Url.class).getValue(); verifyUrlAllowed(url); inputs.add(new Input(type, url)); } } catch (FHIRPathException e) { throw buildExceptionWithIssue("$import invalid parameters with expression in 'input'", e, IssueType.INVALID); } if (inputs.isEmpty()) { throw buildExceptionWithIssue("$import requires 'input' is not found", IssueType.INVALID); } checkAllowedTotalSizeForTenantOrSystem(inputs.size()); return inputs; } }
BulkDataImportUtil { public static List<Input> retrieveInputs(Parameters parameters) throws FHIROperationException { List<Input> inputs = new ArrayList<>(); FHIRPathEvaluator evaluator = FHIRPathEvaluator.evaluator(); EvaluationContext evaluationContext = new EvaluationContext(parameters); try { Collection<FHIRPathNode> result = evaluator.evaluate(evaluationContext, "parameter.where(name = 'input')"); Iterator<FHIRPathNode> iter = result.iterator(); while (iter.hasNext()) { FHIRPathElementNode node = (FHIRPathElementNode) iter.next(); EvaluationContext evaluationContextPartType = new EvaluationContext(node.element()); Collection<FHIRPathNode> resultPartType = evaluator.evaluate(evaluationContextPartType, "part.where(name = 'type').value"); String type = ((FHIRPathElementNode) resultPartType.iterator().next()).element() .as(com.ibm.fhir.model.type.String.class).getValue(); if (!ModelSupport.isResourceType(type)) { throw buildExceptionWithIssue("$import invalid Resource Type 'input'", IssueType.INVALID); } EvaluationContext evaluationContextPartUrl = new EvaluationContext(node.element()); Collection<FHIRPathNode> resultPartUrl = evaluator.evaluate(evaluationContextPartUrl, "part.where(name = 'url').value"); String url = ((FHIRPathElementNode) resultPartUrl.iterator().next()).element() .as(com.ibm.fhir.model.type.Url.class).getValue(); verifyUrlAllowed(url); inputs.add(new Input(type, url)); } } catch (FHIRPathException e) { throw buildExceptionWithIssue("$import invalid parameters with expression in 'input'", e, IssueType.INVALID); } if (inputs.isEmpty()) { throw buildExceptionWithIssue("$import requires 'input' is not found", IssueType.INVALID); } checkAllowedTotalSizeForTenantOrSystem(inputs.size()); return inputs; } private  BulkDataImportUtil(); }
BulkDataImportUtil { public static List<Input> retrieveInputs(Parameters parameters) throws FHIROperationException { List<Input> inputs = new ArrayList<>(); FHIRPathEvaluator evaluator = FHIRPathEvaluator.evaluator(); EvaluationContext evaluationContext = new EvaluationContext(parameters); try { Collection<FHIRPathNode> result = evaluator.evaluate(evaluationContext, "parameter.where(name = 'input')"); Iterator<FHIRPathNode> iter = result.iterator(); while (iter.hasNext()) { FHIRPathElementNode node = (FHIRPathElementNode) iter.next(); EvaluationContext evaluationContextPartType = new EvaluationContext(node.element()); Collection<FHIRPathNode> resultPartType = evaluator.evaluate(evaluationContextPartType, "part.where(name = 'type').value"); String type = ((FHIRPathElementNode) resultPartType.iterator().next()).element() .as(com.ibm.fhir.model.type.String.class).getValue(); if (!ModelSupport.isResourceType(type)) { throw buildExceptionWithIssue("$import invalid Resource Type 'input'", IssueType.INVALID); } EvaluationContext evaluationContextPartUrl = new EvaluationContext(node.element()); Collection<FHIRPathNode> resultPartUrl = evaluator.evaluate(evaluationContextPartUrl, "part.where(name = 'url').value"); String url = ((FHIRPathElementNode) resultPartUrl.iterator().next()).element() .as(com.ibm.fhir.model.type.Url.class).getValue(); verifyUrlAllowed(url); inputs.add(new Input(type, url)); } } catch (FHIRPathException e) { throw buildExceptionWithIssue("$import invalid parameters with expression in 'input'", e, IssueType.INVALID); } if (inputs.isEmpty()) { throw buildExceptionWithIssue("$import requires 'input' is not found", IssueType.INVALID); } checkAllowedTotalSizeForTenantOrSystem(inputs.size()); return inputs; } private  BulkDataImportUtil(); static FHIROperationException buildExceptionWithIssue(String msg, IssueType issueType); static FHIROperationException buildExceptionWithIssue(String msg, Throwable cause, IssueType issueType); static String retrieveInputFormat(Parameters parameters); static String retrieveInputSource(Parameters parameters); static List<Input> retrieveInputs(Parameters parameters); static void checkAllowedTotalSizeForTenantOrSystem(Integer inputSize); static void verifyUrlAllowed(String url); static StorageDetail retrieveStorageDetails(Parameters parameters); }
BulkDataImportUtil { public static List<Input> retrieveInputs(Parameters parameters) throws FHIROperationException { List<Input> inputs = new ArrayList<>(); FHIRPathEvaluator evaluator = FHIRPathEvaluator.evaluator(); EvaluationContext evaluationContext = new EvaluationContext(parameters); try { Collection<FHIRPathNode> result = evaluator.evaluate(evaluationContext, "parameter.where(name = 'input')"); Iterator<FHIRPathNode> iter = result.iterator(); while (iter.hasNext()) { FHIRPathElementNode node = (FHIRPathElementNode) iter.next(); EvaluationContext evaluationContextPartType = new EvaluationContext(node.element()); Collection<FHIRPathNode> resultPartType = evaluator.evaluate(evaluationContextPartType, "part.where(name = 'type').value"); String type = ((FHIRPathElementNode) resultPartType.iterator().next()).element() .as(com.ibm.fhir.model.type.String.class).getValue(); if (!ModelSupport.isResourceType(type)) { throw buildExceptionWithIssue("$import invalid Resource Type 'input'", IssueType.INVALID); } EvaluationContext evaluationContextPartUrl = new EvaluationContext(node.element()); Collection<FHIRPathNode> resultPartUrl = evaluator.evaluate(evaluationContextPartUrl, "part.where(name = 'url').value"); String url = ((FHIRPathElementNode) resultPartUrl.iterator().next()).element() .as(com.ibm.fhir.model.type.Url.class).getValue(); verifyUrlAllowed(url); inputs.add(new Input(type, url)); } } catch (FHIRPathException e) { throw buildExceptionWithIssue("$import invalid parameters with expression in 'input'", e, IssueType.INVALID); } if (inputs.isEmpty()) { throw buildExceptionWithIssue("$import requires 'input' is not found", IssueType.INVALID); } checkAllowedTotalSizeForTenantOrSystem(inputs.size()); return inputs; } private  BulkDataImportUtil(); static FHIROperationException buildExceptionWithIssue(String msg, IssueType issueType); static FHIROperationException buildExceptionWithIssue(String msg, Throwable cause, IssueType issueType); static String retrieveInputFormat(Parameters parameters); static String retrieveInputSource(Parameters parameters); static List<Input> retrieveInputs(Parameters parameters); static void checkAllowedTotalSizeForTenantOrSystem(Integer inputSize); static void verifyUrlAllowed(String url); static StorageDetail retrieveStorageDetails(Parameters parameters);  }