Commit 0fef75d7 authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Restored event collector from running choreography

parent c650444d
......@@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.apache.syncope.core.persistence.api.entity.ChoreographyInstance;
import org.apache.syncope.core.persistence.api.dao.ChoreographyInstanceDAO;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
import org.apache.syncope.core.persistence.api.entity.group.Group;
@Component
......@@ -52,10 +53,17 @@ public class CollectorLogic extends AbstractTransactionalLogic<AbstractBaseBean>
public void saveLogEvent(final EventDataTO data) throws BusinessException {
//Check whether instance of given choreography exists
ChoreographyInstance choreographyInstance = choreographyInstanceDAO.findByChoreographyInstanceId(
data.getChoreographyName(), data.getChoreographyInstanceId()
);
Group choreography = choreographyDAO.findByName(data.getChoreographyName());
ChoreographyInstance choreographyInstance = null;
if (choreography != null) {
GPlainAttr choreographyId = choreography.getPlainAttr("id");
if (choreographyId != null && choreographyId.getUniqueValue() != null) {
choreographyInstance =
choreographyInstanceDAO.findByChoreographyInstanceId(
choreographyId.getUniqueValue().getStringValue(),
data.getChoreographyInstanceId());
}
}
if (choreographyInstance == null) {
throw new BusinessException("Cannot find choreography instance");
......@@ -75,6 +83,7 @@ public class CollectorLogic extends AbstractTransactionalLogic<AbstractBaseBean>
choreographyInstance.add(event);
eventDAO.save(event);
}
public void addInstance(final ChoreographyInstanceTO data) throws BusinessException {
......@@ -86,6 +95,10 @@ public class CollectorLogic extends AbstractTransactionalLogic<AbstractBaseBean>
ChoreographyInstance choreographyInstance = new JPAChoreographyInstance();
choreographyInstance.setChoreographyInstanceId(data.getChoreographyInstanceId());
choreographyInstance.setDescription(data.getInstanceDescription());
GPlainAttr choreographyId = choreography.getPlainAttr("id");
if (choreographyId != null && choreographyId.getUniqueValue() != null) {
choreographyInstance.setChoreographyId(choreographyId.getUniqueValue().getStringValue());
}
choreographyInstanceDAO.save(choreographyInstance);
}
......
......@@ -26,8 +26,8 @@ public interface ChoreographyInstanceDAO extends DAO<ChoreographyInstance> {
ChoreographyInstance findById(String id);
ChoreographyInstance findByChoreographyInstanceId(String choreographyName, String choreographyInstanceId);
ChoreographyInstance findByChoreographyInstanceId(String choreographyId, String choreographyInstanceId);
void save(ChoreographyInstance choreographyInstance);
void delete(ChoreographyInstance choreographyInstance);
......
......@@ -66,15 +66,15 @@ public class JPAChoreographyInstanceDAO extends AbstractDAO<ChoreographyInstance
@Transactional(readOnly = true)
@Override
public ChoreographyInstance findByChoreographyInstanceId(
final String choreographyName,
final String choreographyId,
final String choreographyInstanceId) {
TypedQuery<ChoreographyInstance> query = entityManager().createQuery(
"SELECT e FROM " + JPAChoreographyInstance.class.getSimpleName()
+ " e WHERE e.choreography.name = :choreographyName"
"SELECT e FROM " + JPAChoreographyInstance.class.getSimpleName() + " e"
+ " WHERE e.choreographyId = :choreographyId"
+ " AND e.choreographyInstanceId = :choreographyInstanceId",
ChoreographyInstance.class);
query.setParameter("choreographyName", choreographyName);
query.setParameter("choreographyId", choreographyId);
query.setParameter("choreographyInstanceId", choreographyInstanceId);
List<ChoreographyInstance> results = query.getResultList();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment