Search in sources :

Example 1 with InteractionSearch

use of com.autentia.tnt.dao.search.InteractionSearch in project TNTConcept by autentia.

the class InteractionBean method saveFromOffer.

/**
 * Save bean and stay on it
 * @return forward to list page
 */
public String saveFromOffer() {
    if (interaction.getId() == null) {
        manager.insertEntity(interaction);
    } else {
        manager.updateEntity(interaction);
    }
    // Handle uploads for file field
    if (uploadFile != null) {
        try {
            uploader.replace(Integer.toString(interaction.getId()), oldFile, uploadFile);
        } catch (IOException e) {
            log.error("save - exception uploading field file", e);
            FacesUtils.addErrorMessage("file", "error.fileTransfer", e.getMessage());
        }
    }
    final OfferBean offerBean = (OfferBean) FacesUtils.getBean("offerBean");
    final InteractionSearch search = new InteractionSearch();
    search.setOffer(interaction.getOffer());
    final List<Interaction> interactionList = InteractionManager.getDefault().getAllEntities(search, new SortCriteria("creationDate"));
    final Set<Interaction> interactions = new HashSet<Interaction>(interactionList.size());
    for (Interaction interaction : interactionList) {
        interactions.add(interaction);
    }
    offerBean.setInteractions(interactions);
    restoreOffer();
    return NavigationResults.OFFER_SAVE_INTERACTION;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) InteractionSearch(com.autentia.tnt.dao.search.InteractionSearch) Interaction(com.autentia.tnt.businessobject.Interaction) IOException(java.io.IOException) HashSet(java.util.HashSet)

Aggregations

Interaction (com.autentia.tnt.businessobject.Interaction)1 SortCriteria (com.autentia.tnt.dao.SortCriteria)1 InteractionSearch (com.autentia.tnt.dao.search.InteractionSearch)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1