@Test public void testGetLearningStandards() throws URISyntaxException { String learningStandardId = resourceService.postEntity(learningStandards, createLearningStandardEntity()); String assessmentId = resourceService.postEntity(assessments, createAssessmentEntity(learningStandardId)); requestURI = new java.net.URI(URI + "/" + assessmentId + "/learningStandards"); List<EntityBody> entityBodyList = defaultAssessmentResourceService.getLearningStandards(assessments, assessmentId, learningStandards, requestURI).getEntityBodyList(); assertNotNull("Should return an entity", entityBodyList); assertEquals("Should match", 1, entityBodyList.size()); assertEquals("Should match", "learningStandard", entityBodyList.get(0).get("entityType")); }
@Override public ServiceResponse getLearningStandards(final Resource base, final String idList, final Resource returnResource, final URI requestURI) { final EntityDefinition baseEntityDefinition = resourceHelper.getEntityDefinition(base); final EntityDefinition finalEntityDefinition = resourceHelper.getEntityDefinition(returnResource); final List<String> ids = Arrays.asList(idList.split(",")); ApiQuery apiQuery = resourceServiceHelper.getApiQuery(baseEntityDefinition, requestURI); apiQuery.addCriteria(new NeutralCriteria("_id", "in", ids)); apiQuery.setLimit(0); apiQuery.setOffset(0); List<EntityBody> baseResults = (List<EntityBody>) baseEntityDefinition.getService().list(apiQuery); String key = null; if (returnResource.getResourceType().equals("learningStandards")) { key = "assessmentItem"; } else { key = "objectiveAssessment"; } List<String> finalIds = new ArrayList<String>(); for (EntityBody entityBody : baseResults) { List<Map<String, Object>> items = (List<Map<String, Object>>) entityBody.get(key); if (items != null) { for (Map<String, Object> item : items) { finalIds.addAll((List<String>) item.get(returnResource.getResourceType())); } } } apiQuery = resourceServiceHelper.getApiQuery(finalEntityDefinition, requestURI); apiQuery.addCriteria(new NeutralCriteria("_id", "in", finalIds)); List<EntityBody> finalResults = null; try { finalResults = logicalEntity.getEntities(apiQuery, returnResource.getResourceType()); } catch (UnsupportedSelectorException e) { finalResults = (List<EntityBody>) finalEntityDefinition.getService().list(apiQuery); } return new ServiceResponse(finalResults, finalResults.size()); }
DefaultAssessmentResourceService implements AssessmentResourceService { @Override public ServiceResponse getLearningStandards(final Resource base, final String idList, final Resource returnResource, final URI requestURI) { final EntityDefinition baseEntityDefinition = resourceHelper.getEntityDefinition(base); final EntityDefinition finalEntityDefinition = resourceHelper.getEntityDefinition(returnResource); final List<String> ids = Arrays.asList(idList.split(",")); ApiQuery apiQuery = resourceServiceHelper.getApiQuery(baseEntityDefinition, requestURI); apiQuery.addCriteria(new NeutralCriteria("_id", "in", ids)); apiQuery.setLimit(0); apiQuery.setOffset(0); List<EntityBody> baseResults = (List<EntityBody>) baseEntityDefinition.getService().list(apiQuery); String key = null; if (returnResource.getResourceType().equals("learningStandards")) { key = "assessmentItem"; } else { key = "objectiveAssessment"; } List<String> finalIds = new ArrayList<String>(); for (EntityBody entityBody : baseResults) { List<Map<String, Object>> items = (List<Map<String, Object>>) entityBody.get(key); if (items != null) { for (Map<String, Object> item : items) { finalIds.addAll((List<String>) item.get(returnResource.getResourceType())); } } } apiQuery = resourceServiceHelper.getApiQuery(finalEntityDefinition, requestURI); apiQuery.addCriteria(new NeutralCriteria("_id", "in", finalIds)); List<EntityBody> finalResults = null; try { finalResults = logicalEntity.getEntities(apiQuery, returnResource.getResourceType()); } catch (UnsupportedSelectorException e) { finalResults = (List<EntityBody>) finalEntityDefinition.getService().list(apiQuery); } return new ServiceResponse(finalResults, finalResults.size()); } }
DefaultAssessmentResourceService implements AssessmentResourceService { @Override public ServiceResponse getLearningStandards(final Resource base, final String idList, final Resource returnResource, final URI requestURI) { final EntityDefinition baseEntityDefinition = resourceHelper.getEntityDefinition(base); final EntityDefinition finalEntityDefinition = resourceHelper.getEntityDefinition(returnResource); final List<String> ids = Arrays.asList(idList.split(",")); ApiQuery apiQuery = resourceServiceHelper.getApiQuery(baseEntityDefinition, requestURI); apiQuery.addCriteria(new NeutralCriteria("_id", "in", ids)); apiQuery.setLimit(0); apiQuery.setOffset(0); List<EntityBody> baseResults = (List<EntityBody>) baseEntityDefinition.getService().list(apiQuery); String key = null; if (returnResource.getResourceType().equals("learningStandards")) { key = "assessmentItem"; } else { key = "objectiveAssessment"; } List<String> finalIds = new ArrayList<String>(); for (EntityBody entityBody : baseResults) { List<Map<String, Object>> items = (List<Map<String, Object>>) entityBody.get(key); if (items != null) { for (Map<String, Object> item : items) { finalIds.addAll((List<String>) item.get(returnResource.getResourceType())); } } } apiQuery = resourceServiceHelper.getApiQuery(finalEntityDefinition, requestURI); apiQuery.addCriteria(new NeutralCriteria("_id", "in", finalIds)); List<EntityBody> finalResults = null; try { finalResults = logicalEntity.getEntities(apiQuery, returnResource.getResourceType()); } catch (UnsupportedSelectorException e) { finalResults = (List<EntityBody>) finalEntityDefinition.getService().list(apiQuery); } return new ServiceResponse(finalResults, finalResults.size()); }  }
DefaultAssessmentResourceService implements AssessmentResourceService { @Override public ServiceResponse getLearningStandards(final Resource base, final String idList, final Resource returnResource, final URI requestURI) { final EntityDefinition baseEntityDefinition = resourceHelper.getEntityDefinition(base); final EntityDefinition finalEntityDefinition = resourceHelper.getEntityDefinition(returnResource); final List<String> ids = Arrays.asList(idList.split(",")); ApiQuery apiQuery = resourceServiceHelper.getApiQuery(baseEntityDefinition, requestURI); apiQuery.addCriteria(new NeutralCriteria("_id", "in", ids)); apiQuery.setLimit(0); apiQuery.setOffset(0); List<EntityBody> baseResults = (List<EntityBody>) baseEntityDefinition.getService().list(apiQuery); String key = null; if (returnResource.getResourceType().equals("learningStandards")) { key = "assessmentItem"; } else { key = "objectiveAssessment"; } List<String> finalIds = new ArrayList<String>(); for (EntityBody entityBody : baseResults) { List<Map<String, Object>> items = (List<Map<String, Object>>) entityBody.get(key); if (items != null) { for (Map<String, Object> item : items) { finalIds.addAll((List<String>) item.get(returnResource.getResourceType())); } } } apiQuery = resourceServiceHelper.getApiQuery(finalEntityDefinition, requestURI); apiQuery.addCriteria(new NeutralCriteria("_id", "in", finalIds)); List<EntityBody> finalResults = null; try { finalResults = logicalEntity.getEntities(apiQuery, returnResource.getResourceType()); } catch (UnsupportedSelectorException e) { finalResults = (List<EntityBody>) finalEntityDefinition.getService().list(apiQuery); } return new ServiceResponse(finalResults, finalResults.size()); }  @Override ServiceResponse getLearningStandards(final Resource base, final String idList, final Resource returnResource, final URI requestURI); }
DefaultAssessmentResourceService implements AssessmentResourceService { @Override public ServiceResponse getLearningStandards(final Resource base, final String idList, final Resource returnResource, final URI requestURI) { final EntityDefinition baseEntityDefinition = resourceHelper.getEntityDefinition(base); final EntityDefinition finalEntityDefinition = resourceHelper.getEntityDefinition(returnResource); final List<String> ids = Arrays.asList(idList.split(",")); ApiQuery apiQuery = resourceServiceHelper.getApiQuery(baseEntityDefinition, requestURI); apiQuery.addCriteria(new NeutralCriteria("_id", "in", ids)); apiQuery.setLimit(0); apiQuery.setOffset(0); List<EntityBody> baseResults = (List<EntityBody>) baseEntityDefinition.getService().list(apiQuery); String key = null; if (returnResource.getResourceType().equals("learningStandards")) { key = "assessmentItem"; } else { key = "objectiveAssessment"; } List<String> finalIds = new ArrayList<String>(); for (EntityBody entityBody : baseResults) { List<Map<String, Object>> items = (List<Map<String, Object>>) entityBody.get(key); if (items != null) { for (Map<String, Object> item : items) { finalIds.addAll((List<String>) item.get(returnResource.getResourceType())); } } } apiQuery = resourceServiceHelper.getApiQuery(finalEntityDefinition, requestURI); apiQuery.addCriteria(new NeutralCriteria("_id", "in", finalIds)); List<EntityBody> finalResults = null; try { finalResults = logicalEntity.getEntities(apiQuery, returnResource.getResourceType()); } catch (UnsupportedSelectorException e) { finalResults = (List<EntityBody>) finalEntityDefinition.getService().list(apiQuery); } return new ServiceResponse(finalResults, finalResults.size()); }  @Override ServiceResponse getLearningStandards(final Resource base, final String idList, final Resource returnResource, final URI requestURI);  }