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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations