com.blossomproject.core.group.GroupServiceImpl Maven / Gradle / Ivy
package com.blossomproject.core.group;
import com.blossomproject.core.common.dto.AbstractDTO;
import com.blossomproject.core.common.event.CreatedEvent;
import com.blossomproject.core.common.event.UpdatedEvent;
import com.blossomproject.core.common.mapper.DTOMapper;
import com.blossomproject.core.common.service.AssociationServicePlugin;
import com.blossomproject.core.common.service.GenericCrudServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.transaction.annotation.Transactional;
/**
* Created by Maël Gargadennnec on 03/05/2017.
*/
public class GroupServiceImpl extends GenericCrudServiceImpl implements
GroupService {
private static final Logger logger = LoggerFactory.getLogger(GroupServiceImpl.class);
public GroupServiceImpl(GroupDao dao, DTOMapper mapper,
ApplicationEventPublisher publisher,
PluginRegistry> associationRegistry) {
super(dao, mapper, publisher, associationRegistry);
}
@Override
@Transactional
public GroupDTO create(GroupCreateForm groupCreateForm) throws Exception {
Group groupToCreate = new Group();
groupToCreate.setName(groupCreateForm.getName());
groupToCreate.setDescription(groupCreateForm.getDescription());
GroupDTO savedgroup = this.mapper.mapEntity(this.crudDao.create(groupToCreate));
this.publisher.publishEvent(new CreatedEvent(this, savedgroup));
return savedgroup;
}
@Override
@Transactional
public GroupDTO update(Long groupId, GroupUpdateForm groupUpdateForm) {
Group groupToUpdate = new Group();
groupToUpdate.setName(groupUpdateForm.getName());
groupToUpdate.setDescription(groupUpdateForm.getDescription());
GroupDTO savedgroup = this.mapper.mapEntity(this.crudDao.update(groupId, groupToUpdate));
this.publisher.publishEvent(new UpdatedEvent(this, savedgroup));
return savedgroup;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy