Search in sources :

Example 1 with Interaction

use of com.autentia.tnt.businessobject.Interaction in project TNTConcept by autentia.

the class OfferManager method duplicateOffer.

/* Offer - generated by stajanov (do not edit/delete) */
public Offer duplicateOffer(final Offer offer) {
    final Set<Interaction> interactions = new LinkedHashSet<Interaction>();
    final Set<OfferRole> offerRoles = new LinkedHashSet<OfferRole>();
    final Set<OfferCost> offerCosts = new LinkedHashSet<OfferCost>();
    // copy simple data and delete identificative info
    final Offer duplicatedOffer = (Offer) SerializationUtils.clone(offer);
    duplicatedOffer.setId(null);
    duplicatedOffer.setNumber(null);
    // copy interactions
    if (offer.getInteractions() != null) {
        for (Interaction interaction : offer.getInteractions()) {
            Interaction duplicatedInteraction = (Interaction) SerializationUtils.clone(interaction);
            duplicatedInteraction.setId(null);
            duplicatedInteraction.setOffer(duplicatedOffer);
            interactions.add(duplicatedInteraction);
        }
    }
    duplicatedOffer.setInteractions(interactions);
    // copy roles
    if (offer.getRoles() != null) {
        for (OfferRole offerRole : offer.getRoles()) {
            OfferRole duplicatedRole = (OfferRole) SerializationUtils.clone(offerRole);
            duplicatedRole.setId(null);
            duplicatedRole.setOffer(duplicatedOffer);
            offerRoles.add(duplicatedRole);
        }
    }
    duplicatedOffer.setRoles(offerRoles);
    // copy costs
    if (offer.getCosts() != null) {
        for (OfferCost offerCost : offer.getCosts()) {
            OfferCost duplicatedCost = (OfferCost) SerializationUtils.clone(offerCost);
            duplicatedCost.setId(null);
            duplicatedCost.setOffer(duplicatedOffer);
            offerCosts.add(duplicatedCost);
        }
    }
    duplicatedOffer.setCosts(offerCosts);
    return duplicatedOffer;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Offer(com.autentia.tnt.businessobject.Offer) Interaction(com.autentia.tnt.businessobject.Interaction) OfferCost(com.autentia.tnt.businessobject.OfferCost) OfferRole(com.autentia.tnt.businessobject.OfferRole)

Example 2 with Interaction

use of com.autentia.tnt.businessobject.Interaction in project TNTConcept by autentia.

the class OfferBean method save.

/**
 * Save bean and stay on it
 *
 * @return forward to list page
 */
public String save() {
    doBeforeSave();
    final Set<Interaction> interactionsWithProject = new HashSet<Interaction>();
    if (offer != null && offer.getInteractions() != null) {
        for (Interaction interaction : offer.getInteractions()) {
            if (interaction.getProject() != null) {
                interactionsWithProject.add(interaction);
            }
        }
    }
    if (offer != null) {
        offer.setInteractions(interactionsWithProject);
        if (offer.getId() == null) {
            manager.insertEntity(offer);
        } else {
            manager.updateEntity(offer);
        }
    }
    // nos mantenemos en la pantalla de ediciĆ³n de ofertas
    return null;
}
Also used : Interaction(com.autentia.tnt.businessobject.Interaction) HashSet(java.util.HashSet)

Example 3 with Interaction

use of com.autentia.tnt.businessobject.Interaction in project TNTConcept by autentia.

the class DuplicateOfferTest method insertOfferInteraction.

/**
 * Inserta una interaccion en la oferta
 */
private void insertOfferInteraction() {
    final Set<Interaction> interactions = new LinkedHashSet<Interaction>(1);
    final InteractionTypeDAO interactionTypeDAO = (InteractionTypeDAO) SpringUtilsForTesting.getSpringBean("daoInteractionType");
    final InteractionType interactionType = new InteractionType();
    interactionType.setName("interaccion");
    interactionTypeDAO.insert(interactionType);
    final Interaction interaction = new Interaction();
    interaction.setProject(project);
    interaction.setUser(user);
    interaction.setType(interactionType);
    interaction.setOffer(offer);
    interaction.setCreationDate(new Date());
    interaction.setInterest(InteractionInterest.MEDIUM);
    interaction.setDescription("descripcion de la interaccion");
    interactions.add(interaction);
    offer.setInteractions(interactions);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) InteractionType(com.autentia.tnt.businessobject.InteractionType) Interaction(com.autentia.tnt.businessobject.Interaction) Date(java.util.Date) InteractionTypeDAO(com.autentia.tnt.dao.hibernate.InteractionTypeDAO)

Example 4 with Interaction

use of com.autentia.tnt.businessobject.Interaction in project TNTConcept by autentia.

the class InteractionBean method create.

/**
 * Go to create page
 * @return forward to CREATE page
 */
public String create() {
    interaction = new Interaction();
    // Usuario
    if (getUser() == null) {
        setUser(authMgr.getCurrentPrincipal().getUser());
    }
    interaction.setCreationDate(new Date());
    return NavigationResults.CREATE;
}
Also used : Interaction(com.autentia.tnt.businessobject.Interaction) Date(java.util.Date)

Example 5 with Interaction

use of com.autentia.tnt.businessobject.Interaction 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)8 Date (java.util.Date)3 HashSet (java.util.HashSet)3 SortCriteria (com.autentia.tnt.dao.SortCriteria)2 LinkedHashSet (java.util.LinkedHashSet)2 InteractionType (com.autentia.tnt.businessobject.InteractionType)1 Offer (com.autentia.tnt.businessobject.Offer)1 OfferCost (com.autentia.tnt.businessobject.OfferCost)1 OfferRole (com.autentia.tnt.businessobject.OfferRole)1 InteractionTypeDAO (com.autentia.tnt.dao.hibernate.InteractionTypeDAO)1 InteractionSearch (com.autentia.tnt.dao.search.InteractionSearch)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 UIData (javax.faces.component.UIData)1 SelectItem (javax.faces.model.SelectItem)1