/* * (non-Javadoc) * @see sif3.common.interfaces.QueryProvider#retrieveByQBE(java.lang.Object, sif3.common.model.SIFZone, sif3.common.model.SIFContext, sif3.common.model.PagingInfo, sif3.common.model.RequestMetadata) */ public Object retrieveByQBE( Object exampleObject, SIFZone zone, SIFContext context, PagingInfo pagingInfo, RequestMetadata metadata, ResponseParameters customResponseParams) throws PersistenceException, UnsupportedQueryException, DataTooLargeException { logger.debug("Performing QBE query for: " + exampleObject); if (exampleObject instanceof StudentPersonalType) { ArrayList<StudentPersonalType> studentList = fetchStudents(students, pagingInfo); StudentPersonalCollectionType studentCollection = dmObjectFactory.createStudentPersonalCollectionType(); if (studentList != null) { studentCollection.getStudentPersonal().addAll(studentList); return studentCollection; } else { return null; } } else { throw new IllegalArgumentException( "Expected Object Type = StudentPersonalType. Received Object Type = " + exampleObject.getClass().getSimpleName()); } // throw new UnsupportedQueryException("QBE not supported for StudentPersonals"); }
/* * (non-Javadoc) * @see sif3.common.interfaces.QueryProvider#retrieveByServicePath(sif3.common.model.QueryCriteria, sif3.common.model.SIFZone, sif3.common.model.SIFContext, sif3.common.model.PagingInfo, sif3.common.model.RequestMetadata) */ @Override public Object retrieveByServicePath( QueryCriteria queryCriteria, SIFZone zone, SIFContext context, PagingInfo pagingInfo, RequestMetadata metadata, ResponseParameters customResponseParams) throws PersistenceException, UnsupportedQueryException, DataTooLargeException { logger.debug("Performing query by service path."); if (logger.isDebugEnabled()) { logger.debug("Query Condition (given by service path): " + queryCriteria); } // Check if the query is SchoolInfo or TeachingGroup List<QueryPredicate> predicates = queryCriteria.getPredicates(); if ((predicates != null) && (predicates.size() == 1)) // ensure it is a valid condition { if ("SchoolInfos".equals(predicates.get(0).getSubject())) { // Assume all students known from the file are at the same school. return retrieve(zone, context, pagingInfo, metadata, customResponseParams); } else if ("TeachingGroups".equals(predicates.get(0).getSubject())) { logger.debug( "Retrieve Students for Teaching Group (class) " + predicates.get(0).getValue() + " for " + getZoneAndContext(zone, context) + " and RequestMetadata = " + metadata); ArrayList<StudentPersonalType> studentList = fetchStudents(teachingGroupStudents, pagingInfo); StudentPersonalCollectionType studentCollection = dmObjectFactory.createStudentPersonalCollectionType(); if (studentList != null) { studentCollection.getStudentPersonal().addAll(studentList); return studentCollection; } else { return null; } } else { throw new UnsupportedQueryException( "The query condition (driven by the service path) " + queryCriteria + " is not supported by the provider."); } } else // not supported query (only single level service path query supported by this provider) { throw new UnsupportedQueryException( "The query condition (driven by the service path) " + queryCriteria + " is not supported by the provider."); } }
/* (non-Javadoc) * @see sif3.common.interfaces.Provider#retrive(sif3.common.model.SIFZone, sif3.common.model.SIFContext, sif3.common.model.PagingInfo) */ @Override public Object retrieve( SIFZone zone, SIFContext context, PagingInfo pagingInfo, RequestMetadata metadata, ResponseParameters customResponseParams) throws PersistenceException, UnsupportedQueryException, DataTooLargeException { logger.debug( "Retrieve Students for " + getZoneAndContext(zone, context) + " and RequestMetadata = " + metadata); logger.debug("ChangedSince Date: " + metadata.getRequestParameter("ChangedSince")); logger.debug("Custom HTTP Header (customHdr): " + metadata.getHTTPParameter("customHdr")); // Should go all the way to consumer customResponseParams.addHTTPHeaderParameter("testHTTPResponseParam", "testValue"); // Should override a default from the provider properties file. customResponseParams.addHTTPHeaderParameter("test", "providerPropertyFileOverride"); // Should be overridden by framework customResponseParams.addHTTPHeaderParameter( ResponseHeaderConstants.HDR_DATE_TIME, "ignore this date/time"); if (pagingInfo == null) { throw new DataTooLargeException( "No paging info is provided. Please provide navigationPage and navigationPageSize."); } else { // We may want to set the navigationID! Here we set it as a GUID but only if we are on the // first page because it is expected that in subsequent // paged calls that the consumer would provide that id. if (pagingInfo.getCurrentPageNo() == CommonConstants.FIRST_PAGE) { // pagingInfo.setNavigationId(UUIDGenerator.getUUID()); } } ArrayList<StudentPersonalType> studentList = fetchStudents(students, pagingInfo); StudentPersonalCollectionType studentCollection = dmObjectFactory.createStudentPersonalCollectionType(); if (studentList != null) { studentCollection.getStudentPersonal().addAll(studentList); return studentCollection; } else { return null; } }