当前位置: 首页>>代码示例>>Java>>正文


Java Specifications类代码示例

本文整理汇总了Java中org.springframework.data.jpa.domain.Specifications的典型用法代码示例。如果您正苦于以下问题:Java Specifications类的具体用法?Java Specifications怎么用?Java Specifications使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Specifications类属于org.springframework.data.jpa.domain包,在下文中一共展示了Specifications类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: preloadPermitEntities

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
private List<HarvestPermit> preloadPermitEntities() {
    final Person person = activeUserService.getActiveUser().getPerson();

    if (person == null) {
        return emptyList();
    }

    final Specifications<HarvestPermit> harvestsAsListAndReportNotDone = Specifications
            .where(equal(HarvestPermit_.harvestsAsList, Boolean.TRUE))
            .and(harvestReportNotDone());

    final Specification<HarvestPermit> harvestsNotAsList = equal(HarvestPermit_.harvestsAsList, Boolean.FALSE);

    final Specification<HarvestPermit> contactPersonAndPermitUsable = JpaSpecs.and(
            isPermitContactPerson(person),
            JpaSpecs.or(harvestsAsListAndReportNotDone, harvestsNotAsList));

    return harvestPermitRepository.findAll(JpaSpecs.and(
            JpaSpecs.or(
                    contactPersonAndPermitUsable,
                    withHarvestAuthor(person),
                    withHarvestShooter(person)),
            IS_NOT_ANY_MOOSELIKE_PERMIT));
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:25,代码来源:MobileGameDiaryFeature.java

示例2: getHarvestReportFieldses

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
private List<HarvestReportFields> getHarvestReportFieldses(
        @Nullable final LocalDate date, @Nullable final Integer gameSpeciesCode) {

    final Specification<HarvestReportFields> withSpeciesCode = gameSpeciesCode == null
            ? JpaSpecs.conjunction()
            : JpaSpecs.equal(HarvestReportFields_.species, GameSpecies_.officialCode, gameSpeciesCode);

    Specifications<HarvestReportFields> spec =
            where(JpaSpecs.equal(HarvestReportFields_.usedWithPermit, true))
                    .and(withSpeciesCode);

    if (date != null) {
        spec = spec.and(
                JpaSpecs.withinInterval(HarvestReportFields_.beginDate, HarvestReportFields_.endDate, date));
    }

    return harvestReportFieldsRepository.findAll(spec);
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:19,代码来源:HarvestReportFeature.java

示例3: groupRelationsInternal

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
private static <T, U, V> Map<V, List<U>> groupRelationsInternal(
        @Nonnull final Collection<? extends T> objects,
        @Nonnull final Specification<U> inSpec,
        @Nonnull final JpaSpecificationExecutor<U> repository,
        @Nonnull final Function<? super U, ? extends V> keyMapper,
        @Nullable final Specification<U> constraint,
        @Nullable final Sort sortCriteria) {

    Objects.requireNonNull(objects, "objects must not be null");
    Objects.requireNonNull(inSpec, "inSpec must not be null");
    Objects.requireNonNull(repository, "repository must not be null");

    if (objects.isEmpty()) {
        return new HashMap<>(0);
    }

    final Specification<U> compoundSpec =
            constraint == null ? inSpec : Specifications.where(inSpec).and(constraint);

    final List<U> list = sortCriteria != null
            ? repository.findAll(compoundSpec, sortCriteria) : repository.findAll(compoundSpec);
    return F.nullSafeGroupBy(list, keyMapper);
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:24,代码来源:JpaGroupingUtils.java

示例4: findAllActive

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
@Override
public Iterable<T> findAllActive(Iterable<ID> ids) {
	if (ids == null || !ids.iterator().hasNext())
		return Collections.emptyList();

	if (entityInformation.hasCompositeId()) {
		List<T> results = new ArrayList<T>();

		for (ID id : ids)
			results.add(findOneActive(id));

		return results;
	}

	ByIdsSpecification<T> specification = new ByIdsSpecification<T>(entityInformation);
	TypedQuery<T> query = getQuery(Specifications.where(specification).and(notDeleted()), (Sort) null);

	return query.setParameter(specification.parameter, ids).getResultList();
}
 
开发者ID:dzinot,项目名称:spring-boot-jpa-data-rest-soft-delete,代码行数:20,代码来源:SoftDeletesRepositoryImpl.java

示例5: getHousingUnits

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
public List<HousingInventory> getHousingUnits(UUID projectId,boolean isFamily,Integer members){
	Object[] capacity = new Integer[]{members,members-1};
	
	Specification<HousingInventory> spec = Specifications.where(new Specification<HousingInventory>() {

		@Override
		public Predicate toPredicate(Root<HousingInventory> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
  
			return criteriaBuilder.and(criteriaBuilder.equal(root.get("projectId"),projectId),
					criteriaBuilder.equal(root.get("familyUnit"), isFamily),
					criteriaBuilder.upper(root.get("bedsCapacity")).in(capacity));				
		}
	});
	
  return serviceFactory.getRepositoryFactory().getHousingUnitsRepository().findAll(spec);
	
}
 
开发者ID:hserv,项目名称:coordinated-entry,代码行数:18,代码来源:HousingUnitServiceImpl.java

示例6: getScoreStatus

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
public BatchProcessModel getScoreStatus(String projectGroup){
	Specification<BatchProcessEntity> specification = Specifications.where(new Specification<BatchProcessEntity>() {

		@Override
		public Predicate toPredicate(Root<BatchProcessEntity> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
			
		return criteriaBuilder.and(
					criteriaBuilder.equal(root.get("projectGroupCode"),projectGroup),
					criteriaBuilder.equal(root.get("processType"),Constants.SCORES_PROCESS_BATCH)
					);
		}	
	});
	
	Sort sort = new Sort(Direction.DESC,"dateUpdated");
	List<BatchProcessEntity> entities = repositoryFactory.getBatchProcessRepository().findAll(specification,sort);
	
	if(!entities.isEmpty())
			return batchProcessTranslator.translate(entities.get(0));
	 return null;
}
 
开发者ID:hserv,项目名称:coordinated-entry,代码行数:21,代码来源:BatchProcessServiceImpl.java

示例7: getScoreStatusHistory

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
public Page<BatchProcessEntity> getScoreStatusHistory(String projectGroup,Pageable pageable){
	Specification<BatchProcessEntity> specification = Specifications.where(new Specification<BatchProcessEntity>() {

		@Override
		public Predicate toPredicate(Root<BatchProcessEntity> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
			
		return criteriaBuilder.and(
					criteriaBuilder.equal(root.get("projectGroupCode"),projectGroup),
					criteriaBuilder.equal(root.get("processType"),Constants.SCORES_PROCESS_BATCH)
				);
		}	
	});
	
	Sort sort = new Sort(Direction.DESC,"dateUpdated");
	PageRequest pageRequest = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(),sort);
	Page<BatchProcessEntity> entities = repositoryFactory.getBatchProcessRepository().findAll(specification,pageRequest);
	
	 return entities;
}
 
开发者ID:hserv,项目名称:coordinated-entry,代码行数:20,代码来源:BatchProcessServiceImpl.java

示例8: getEligibleClients

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
public List<EligibleClient> getEligibleClients(Integer programType, String projectGroup,String spdatLabel) {
	
	Specification<EligibleClient> specification = Specifications.where(new Specification<EligibleClient>() {

		@Override
		public Predicate toPredicate(Root<EligibleClient> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
			
		return criteriaBuilder.and(
						criteriaBuilder.equal(root.get("programType"),programType+""),
						criteriaBuilder.equal(root.get("projectGroupCode"),projectGroup),
					criteriaBuilder.equal(root.get("spdatLabel"),spdatLabel),
					criteriaBuilder.equal(root.get("deleted"), false),
					criteriaBuilder.equal(root.get("ignoreMatchProcess"),false),
					criteriaBuilder.equal(root.get("matched"),false));
		}	
	});
	
	Sort sort = new Sort(Direction.ASC,"cocScore","surveyDate");
	return repositoryFactory.getEligibleClientsRepository().findAll(specification,sort);
}
 
开发者ID:hserv,项目名称:coordinated-entry,代码行数:21,代码来源:EligibleClientServiceImpl.java

示例9: build

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
/**
 * build specification.
 *
 * @return Specification
 */
public Specification<T> build() {
  if (this.params.size() == 0) {
    return null;
  }

  final List<Specification<T>> specs = new ArrayList<Specification<T>>();
  for (final SearchCriteria param : this.params) {
    specs.add(this.createSpecification(param));
  }

  Specification<T> result = specs.get(0);
  for (int i = 1; i < specs.size(); i++) {
    result = Specifications.where(result).and(specs.get(i));
  }
  return result;
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators-example,代码行数:22,代码来源:AbstractSpecificationsBuilderTemplate.java

示例10: getResultSpec

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
private Specification<T> getResultSpec(List<SearchCriteries.SearchCriteriaResult> criteries) {
    if (criteries == null || criteries.isEmpty()) {
        return null;
    }

    SearchCriteries.SearchCriteriaResult first = criteries.get(0);

    Specification<T> resultSpec = createSpec(criteries, 0);
    Boolean isNextConditionAnd = first.getNextAnd();
    for (int i = 1; i < criteries.size(); i++) {
        if (isNextConditionAnd) {
            resultSpec = Specifications.where(resultSpec).and(createSpec(criteries, i));
        } else {
            resultSpec = Specifications.where(resultSpec).or(createSpec(criteries, i));
        }
        isNextConditionAnd = criteries.get(i).getNextAnd();
    }

    return resultSpec;
}
 
开发者ID:imCodePartnerAB,项目名称:iVIS,代码行数:21,代码来源:AbstractService.java

示例11: fail_to_update_application_with_existing_code

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
@Test(expected = DuplicateApplicationException.class)
public void fail_to_update_application_with_existing_code() throws DuplicateApplicationException, ApplicationNotFoundException,
		PaasUserNotFoundException {
	// given Bob is authenticated
	TestHelper.loginAsAdmin();
	// given application with label aLabel and code aCode exists
	Application application = new Application("aLabel", "aCode");
	Mockito.when(applicationRepository.findByUid(application.getUID())).thenReturn(new Application("aLabel", "aCode"));
	// given application with code anotherCode exists
	Mockito.when(applicationRepository.findOne(any(Specifications.class))).thenReturn(new Application("anotherLabel", "anotherCode"));
	// when I update application
	application.setLabel("aLabel");
	application.setCode("anotherCode");
	manageApplication.updateApplication(application);
	// then It should fail
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:17,代码来源:ManageApplicationImplTest.java

示例12: fail_to_update_application_with_existing_label

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
@Test(expected = DuplicateApplicationException.class)
public void fail_to_update_application_with_existing_label() throws DuplicateApplicationException, ApplicationNotFoundException,
		PaasUserNotFoundException {
	// given Bob is authenticated
	TestHelper.loginAsAdmin();
	// given application with label aLabel and code aCode exists
	Application application = new Application("aLabel", "aCode");
	Mockito.when(applicationRepository.findByUid(application.getUID())).thenReturn(new Application("aLabel", "aCode"));
	// given application with label anotherLabel exists
	Mockito.when(applicationRepository.findOne(any(Specifications.class))).thenReturn(new Application("anotherLabel", "anotherCode"));
	// when I update application
	application.setLabel("anotherLabel");
	application.setCode("aCode");
	manageApplication.updateApplication(application);
	// then It should fail
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:17,代码来源:ManageApplicationImplTest.java

示例13: viewingAVoteShouldWork

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
@Test
public void viewingAVoteShouldWork() throws Exception {

    testGroup.addMember(sessionTestUser, BaseRoles.ROLE_GROUP_ORGANIZER, GroupJoinMethod.ADDED_BY_OTHER_MEMBER, null);
    EventLog eventLog = new EventLog(sessionTestUser, voteEvent, EventLogType.RSVP, EventRSVPResponse.YES);
    ResponseTotalsDTO rsvpTotalsDTO = ResponseTotalsDTO.makeForTest(1, 2, 3, 4, 5);

    when(userManagementServiceMock.findByInputNumber(testUserPhone)).thenReturn(sessionTestUser);
    when(voteBrokerMock.load(voteEvent.getUid())).thenReturn(voteEvent);
    when(eventLogRepositoryMock.findOne(any(Specifications.class))).thenReturn(eventLog);
    when(eventLogBrokerMock.hasUserRespondedToEvent(voteEvent, sessionTestUser)).thenReturn(true);
    when(eventLogBrokerMock.getResponseCountForEvent(voteEvent)).thenReturn(rsvpTotalsDTO);

    mockMvc.perform(get(path + "/view/{id}/{phoneNumber}/{code}", voteEvent.getUid(), testUserPhone, testUserCode)).andExpect(status().is2xxSuccessful());

    verify(userManagementServiceMock).findByInputNumber(testUserPhone);
    verify(voteBrokerMock).load(voteEvent.getUid());
    verify(voteBrokerMock).fetchVoteResults(sessionTestUser.getUid(), voteEvent.getUid(), false);
    verify(eventLogRepositoryMock).findOne(any(Specifications.class));
}
 
开发者ID:grassrootza,项目名称:grassroot-platform,代码行数:21,代码来源:VoteRestControllerTest.java

示例14: viewRsvpingShouldWork

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
@Test
public void viewRsvpingShouldWork() throws Exception {
    testGroup.addMember(sessionTestUser, BaseRoles.ROLE_GROUP_ORGANIZER, GroupJoinMethod.ADDED_BY_OTHER_MEMBER, null);
    ResponseTotalsDTO testResponseTotalsDTO = ResponseTotalsDTO.makeForTest(40, 20, 10, 0, 70);

    when(userManagementServiceMock.findByInputNumber(testUserPhone)).thenReturn(sessionTestUser);
    when(eventBrokerMock.loadMeeting(meetingEvent.getUid())).thenReturn(meetingEvent);
    when(eventLogRepositoryMock.findOne(any(Specifications.class)))
            .thenReturn(new EventLog(sessionTestUser, meetingEvent, EventLogType.RSVP, EventRSVPResponse.YES));
    when(eventLogBrokerMock.hasUserRespondedToEvent(meetingEvent, sessionTestUser)).thenReturn(false);
    when(eventLogBrokerMock.getResponseCountForEvent(meetingEvent)).thenReturn(testResponseTotalsDTO);
    mockMvc.perform(get(path + "/view/{id}/{phoneNumber}/{code}", meetingEvent.getUid(), testUserPhone, testUserCode))
            .andExpect(status().is2xxSuccessful());
    verify(userManagementServiceMock).findByInputNumber(testUserPhone);
    verify(eventBrokerMock).loadMeeting(meetingEvent.getUid());
    verify(eventLogRepositoryMock).findOne(any(Specifications.class));
    verify(eventLogBrokerMock).getResponseCountForEvent(meetingEvent);

}
 
开发者ID:grassrootza,项目名称:grassroot-platform,代码行数:20,代码来源:MeetingRestControllerTest.java

示例15: sendTodoReminders

import org.springframework.data.jpa.domain.Specifications; //导入依赖的package包/类
@Scheduled(fixedRate = 300000) //runs every 5 minutes
public void sendTodoReminders() {
    List<Todo> todos = todoRepository.findAll(Specifications.where(TodoSpecifications.notCancelled())
            .and(TodoSpecifications.remindersLeftToSend())
            .and(TodoSpecifications.reminderTimeBefore(Instant.now()))
            .and((root, query, cb) -> cb.isFalse(root.get(Todo_.completed)))
            .and(TodoSpecifications.todoNotConfirmedByCreator()));

    logger.info("Sending scheduled reminders for {} todos, after using threshold of {}", todos.size(), COMPLETION_PERCENTAGE_BOUNDARY);
    for (Todo todo : todos) {
        try {
            todoBroker.sendScheduledReminder(todo.getUid());
        } catch (Throwable th) {
            logger.error("Error while sending reminder for todo " + todo + ": " + th.getMessage(), th);
        }
    }
}
 
开发者ID:grassrootza,项目名称:grassroot-platform,代码行数:18,代码来源:ScheduledTasks.java


注:本文中的org.springframework.data.jpa.domain.Specifications类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。