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


Java HandleBeforeCreate类代码示例

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


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

示例1: processInventoryTransfer

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
public void processInventoryTransfer(InventoryTransfer inventoryTransfer) {
    InventoryItem sourceInventory = inventoryRepository.findByProductAndFacility(inventoryTransfer.getProductInstance(),
            inventoryTransfer.getFromFacility());
    if (sourceInventory == null) {
        sourceInventory = new InventoryItem(inventoryTransfer.getProductInstance(), inventoryTransfer.getFromFacility());
    }
    InventoryItem targetInventory = inventoryRepository.findByProductAndFacility(inventoryTransfer.getProductInstance(),
            inventoryTransfer.getToFacility());
    if (targetInventory == null) {
        targetInventory = new InventoryItem(inventoryTransfer.getProductInstance(), inventoryTransfer.getToFacility());
    }
    sourceInventory.bookOutgoing(inventoryTransfer);
    targetInventory.bookIncoming(inventoryTransfer);
    inventoryRepository.save(sourceInventory);
    inventoryRepository.save(targetInventory);
}
 
开发者ID:thomasletsch,项目名称:moserp,代码行数:18,代码来源:InventoryTransferEventHandler.java

示例2: onRelatedPublicationBeforeSavedOrCreated

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
/**
 * Do checks with the related publication before delete or save operations.
 * 
 * @param relatedPublication the updated or deleted related 
 *     publication before the delete or save process 
 */
@HandleBeforeCreate
@HandleBeforeSave
public void onRelatedPublicationBeforeSavedOrCreated(RelatedPublication relatedPublication) {
  RelatedPublication oldPublication = this.relatedPublicationRepository
      .findOne(relatedPublication.getId());
  
  if (oldPublication != null) {      
    List<String> deletedStudyIds = new ArrayList<>(oldPublication.getStudyIds());
    deletedStudyIds.removeAll(relatedPublication.getStudyIds());
    enqueueStudiesIfProjectIsReleased(deletedStudyIds);
    
    List<String> addedStudyIds = new ArrayList<>(relatedPublication.getStudyIds());
    addedStudyIds.removeAll(oldPublication.getStudyIds());
    enqueueStudiesIfProjectIsReleased(addedStudyIds);
    
    if (!oldPublication.getSourceReference().equals(relatedPublication.getSourceReference())) {
      enqueueStudiesIfProjectIsReleased(relatedPublication.getStudyIds());
    }
  } else {
    enqueueStudiesIfProjectIsReleased(relatedPublication.getStudyIds());
  }
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:29,代码来源:DaraUpdateQueueService.java

示例3: handleProposalPublicationPreCreated

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
@Transactional
@PreAuthorize("hasRole('COORDINATOR')")
public void handleProposalPublicationPreCreated(ProposalPublication proposalPublication) {
    logger.info("Before creating: {}", proposalPublication.toString());

    ProposalSubmission submission = proposalPublication.getPublishes();
    Assert.notNull(submission, "Trying to publish un-existing submission");

    Proposal proposal = submission.getSubmits();
    Assert.isTrue(proposal.getStatus().equals(Proposal.Status.SUBMITTED),
            "Invalid proposal status '"+proposal.getStatus()+"', should be '"+ Proposal.Status.SUBMITTED+"'");

    String username = SecurityContextHolder.getContext().getAuthentication().getName();
    Coordinator coordinator = coordinatorRepository.findOne(username);
    proposalPublication.setAgent(coordinator);

    proposal.setStatus(Proposal.Status.PUBLISHED);
    proposalRepository.save(proposal);

    String subject = "Proposal Published";
    String message = "Dear Proponent, \n\n" +
            "Your proposal with title \"" +
            proposal.getTitle() + "has been published. \n\n" +
            "Best regards, \n\n" +
            username;

    mailService.sendMessage(proposal.getCreator().getEmail(), subject, message);
}
 
开发者ID:UdL-EPS-SoftArch,项目名称:entsoftarch-1516-server,代码行数:30,代码来源:ProposalPublishEventHandler.java

示例4: handleProposalRegistrationPreCreate

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
@Transactional
public void handleProposalRegistrationPreCreate(ProposalRegistration proposalRegistration){
    logger.info("Before creating: {}", proposalRegistration.toString());

    ProposalPublication publication = proposalRegistration.getRegisters();
    ProposalSubmission submission = publication.getPublishes();
    Proposal proposal = submission.getSubmits();

    proposal.setStatus(Proposal.Status.REGISTERED);
    proposalRepository.save(proposal);
}
 
开发者ID:UdL-EPS-SoftArch,项目名称:entsoftarch-1516-server,代码行数:13,代码来源:ProposalRegistrationEventHandler.java

示例5: handleProposalStudentOfferPreCreate

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
@Transactional
@PreAuthorize("hasRole('STUDENT')")
public void handleProposalStudentOfferPreCreate(StudentOffer studentOffer) {
    logger.info("Before creating: {}", studentOffer.toString());

    ProposalPublication publication = studentOffer.getTarget();
    ProposalSubmission submission = publication.getPublishes();
    Proposal proposal = submission.getSubmits();

    Assert.isTrue(proposal.getStatus().equals(Proposal.Status.PUBLISHED),
            "Invalid proposal status '"+proposal.getStatus()+"', should be '"+ Proposal.Status.PUBLISHED+"'");

    String username = SecurityContextHolder.getContext().getAuthentication().getName();
    studentOffer.setAgent(studentRepository.findOne(username));

    List<StudentOffer> listPreviousStudentOffers =
            studentOfferRepository.findByAgentAndTarget(studentOffer.getAgent(), publication);
    Assert.isTrue(listPreviousStudentOffers.isEmpty(), "Repeated StudentOffer");

    Proponent proponent = proposal.getCreator();

    String subject = "Student Offer";
    String message = "Dear proponent, \n\n" +
                     "Please, be aware that a new Student Offer of the proposal \"" + proposal.getTitle() + "\" "+
                     "has been created by "+ studentOffer.getAgent().getEmail()+" \n\n" +
                     "Best regards, \n\n" +
                     "Thesis Market";

    mailService.sendMessage(proponent.getEmail(),subject,message);
}
 
开发者ID:UdL-EPS-SoftArch,项目名称:entsoftarch-1516-server,代码行数:32,代码来源:StudentOfferEventHandler.java

示例6: handleBeforeCreate

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
/**
 * Method is only called when using REST
 * Direct repository manipulation doesn't trigger event
 */
@HandleBeforeCreate
public void handleBeforeCreate(JobOffer jobOffer) {

    Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserDetails currentUser = (UserDetails) principal;

    RestAccessKey restAccessKey = restAccessKeyRepository.findByOwnerNameAndActive(currentUser.getUsername(), 1);

    jobOffer.setOwner(restAccessKey);
}
 
开发者ID:alv-ch,项目名称:jobroom-api,代码行数:15,代码来源:JobOfferEventHandler.java

示例7: handleBookmarkCreate

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
public void handleBookmarkCreate(Bookmark bookmark)
{
    bookmark.setCreated(new Date());
    bookmark.setUrl(bookmark.getUrl().trim());

}
 
开发者ID:BernhardWenzel,项目名称:scraping-microservice-java-python-rabbitmq,代码行数:8,代码来源:BookmarkEventHandler.java

示例8: beforePizzaSave

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
public void beforePizzaSave(Pizza pizza) {
  pizza.setPrice(pizza.getPrice().multiply(new BigDecimal("0.9")));
}
 
开发者ID:jcmellado,项目名称:sdre,代码行数:5,代码来源:PizzaEventHandler.java

示例9: handleBeforeCreate

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
public void handleBeforeCreate(Moto moto) {
    System.out.println("before-create: " + moto.toString());
}
 
开发者ID:guirsouza,项目名称:spring-data-rest-test,代码行数:5,代码来源:MotoEventHandler.java

示例10: handleBeforeCreate

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
/**
 * Give submission an ID and draft status on creation
 *
 * @param submission
 */
@HandleBeforeCreate
public void handleBeforeCreate(Submission submission) {
    submissionHelperService.setupNewSubmission(submission);
    submissionEventService.submissionCreated(submission);
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:11,代码来源:SubmissionEventHandler.java

示例11: beforeSave

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
@HandleBeforeSave
public void beforeSave(User user) {
    user.setPassword(passwordEncoder.encode(user.getPassword()));
    user.setRoles(Arrays.asList("ROLE_USER"));
}
 
开发者ID:nidi3,项目名称:jwt-with-spring,代码行数:7,代码来源:UserEventHandler.java

示例12: processOutgoingDelivery

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
public void processOutgoingDelivery(OutgoingDelivery OutgoingDelivery) {
    OutgoingDelivery.getItems().forEach(item -> bookItem(OutgoingDelivery.getFromFacility(), item));
}
 
开发者ID:thomasletsch,项目名称:moserp,代码行数:5,代码来源:OutgoingDeliveryEventHandler.java

示例13: processIncomingDelivery

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
public void processIncomingDelivery(IncomingDelivery incomingDelivery) {
    incomingDelivery.getItems().forEach(item -> bookItem(incomingDelivery.getToFacility(), item));
}
 
开发者ID:thomasletsch,项目名称:moserp,代码行数:5,代码来源:IncomingDeliveryEventHandler.java

示例14: checkCreateAuthority

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
@PreAuthorize("hasRole('ROLE_ADMIN')")
public void checkCreateAuthority(Category category) {
	log.debug("Creating category {}", category);
}
 
开发者ID:perrywang,项目名称:dionysus,代码行数:6,代码来源:CategoryEventListener.java

示例15: checkCreateAuthority

import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
@PreAuthorize("hasRole('ROLE_ADMIN')")
public void checkCreateAuthority(Article article) {
	log.debug("Creating article {}", article);
}
 
开发者ID:perrywang,项目名称:dionysus,代码行数:6,代码来源:ArticleEventHandler.java


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