本文整理汇总了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);
}
示例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());
}
}
示例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);
}
示例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);
}
示例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);
}
示例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")));
}
示例9: handleBeforeCreate
import org.springframework.data.rest.core.annotation.HandleBeforeCreate; //导入依赖的package包/类
@HandleBeforeCreate
public void handleBeforeCreate(Moto moto) {
System.out.println("before-create: " + moto.toString());
}
示例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);
}
示例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"));
}
示例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));
}
示例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));
}
示例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);
}
示例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);
}