com.netgrif.application.engine.history.service.HistoryService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of application-engine Show documentation
Show all versions of application-engine Show documentation
System provides workflow management functions including user, role and data management.
package com.netgrif.application.engine.history.service;
import com.netgrif.application.engine.history.domain.baseevent.EventLog;
import com.netgrif.application.engine.history.domain.baseevent.repository.EventLogRepository;
import com.netgrif.application.engine.history.domain.caseevents.CreateCaseEventLog;
import com.netgrif.application.engine.history.domain.caseevents.DeleteCaseEventLog;
import com.netgrif.application.engine.history.domain.dataevents.GetDataEventLog;
import com.netgrif.application.engine.history.domain.dataevents.SetDataEventLog;
import com.netgrif.application.engine.history.domain.petrinetevents.DeletePetriNetEventLog;
import com.netgrif.application.engine.history.domain.petrinetevents.ImportPetriNetEventLog;
import com.netgrif.application.engine.history.domain.taskevents.AssignTaskEventLog;
import com.netgrif.application.engine.history.domain.taskevents.CancelTaskEventLog;
import com.netgrif.application.engine.history.domain.taskevents.FinishTaskEventLog;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class HistoryService implements IHistoryService {
protected String clazz = "', _class: '";
@Autowired
private EventLogRepository eventLogRepository;
@Autowired
private MongoTemplate mongoTemplate;
@Override
@Async
public void save(EventLog eventLog) {
eventLogRepository.save(eventLog);
}
@Override
public List findAllByIds(List eventIds) {
return eventLogRepository.findAllById(eventIds);
}
@Override
public List findAllCreateCaseEventLogsByCaseId(ObjectId caseId) {
return findAllByCaseId(caseId.toString(), CreateCaseEventLog.class);
}
@Override
public List findAllDeleteCaseEventLogsByCaseId(ObjectId caseId) {
return findAllByCaseId(caseId.toString(), DeleteCaseEventLog.class);
}
@Override
public List findAllCreateCaseEventLogsByCaseId(String caseId) {
return findAllByCaseId(caseId, CreateCaseEventLog.class);
}
@Override
public List findAllDeleteCaseEventLogsByCaseId(String caseId) {
return findAllByCaseId(caseId, DeleteCaseEventLog.class);
}
@Override
public List findAllGetDataEventLogsByCaseId(ObjectId caseId) {
return findAllByCaseId(caseId.toString(), GetDataEventLog.class);
}
@Override
public List findAllGetDataEventLogsByTaskId(ObjectId taskId) {
return findAllByTaskId(taskId.toString(), GetDataEventLog.class);
}
@Override
public List findAllGetDataEventLogsByCaseId(String caseId) {
return findAllByCaseId(caseId, GetDataEventLog.class);
}
@Override
public List findAllGetDataEventLogsByTaskId(String taskId) {
return findAllByTaskId(taskId, GetDataEventLog.class);
}
@Override
public List findAllSetDataEventLogsByCaseId(ObjectId caseId) {
return findAllByCaseId(caseId.toString(), SetDataEventLog.class);
}
@Override
public List findAllSetDataEventLogsByCaseId(String caseId) {
return findAllByCaseId(caseId, SetDataEventLog.class);
}
@Override
public List findAllSetDataEventLogsByTaskId(ObjectId taskId) {
return findAllByTaskId(taskId.toString(), SetDataEventLog.class);
}
@Override
public List findAllDeletePetriNetEventLogsByNetId(ObjectId netId) {
return findAllByNetId(netId, DeletePetriNetEventLog.class);
}
@Override
public List findAllSetDataEventLogsByTaskId(String taskId) {
return findAllByTaskId(taskId, SetDataEventLog.class);
}
@Override
public List findAllImportPetriNetEventLogsByNetId(ObjectId netId) {
return findAllByNetId(netId, ImportPetriNetEventLog.class);
}
@Override
public List findAllAssignTaskEventLogsByTaskId(ObjectId taskId) {
return findAllByTaskId(taskId.toString(), AssignTaskEventLog.class);
}
@Override
public List findAllAssignTaskEventLogsByTaskId(String taskId) {
return findAllByTaskId(taskId, AssignTaskEventLog.class);
}
@Override
public List findAllAssignTaskEventLogsByUserId(String userId) {
return findAllByUserId(userId, AssignTaskEventLog.class);
}
@Override
public List findAllAssignTaskEventLogsByCaseId(String caseId) {
return findAllByCaseId(caseId, AssignTaskEventLog.class);
}
@Override
public List findAllCancelTaskEventLogsByTaskId(String taskId) {
return findAllByTaskId(taskId, CancelTaskEventLog.class);
}
@Override
public List findAllCancelTaskEventLogsByTaskId(ObjectId taskId) {
return findAllByTaskId(taskId.toString(), CancelTaskEventLog.class);
}
@Override
public List findAllCancelTaskEventLogsByUserId(String userId) {
return findAllByUserId(userId, CancelTaskEventLog.class);
}
@Override
public List findAllFinishTaskEventLogsByTaskId(String taskId) {
return findAllByTaskId(taskId, FinishTaskEventLog.class);
}
@Override
public List findAllFinishTaskEventLogsByTaskId(ObjectId taskId) {
return findAllByTaskId(taskId.toString(), FinishTaskEventLog.class);
}
@Override
public List findAllFinishTaskEventLogsByUserId(String userId) {
return findAllByUserId(userId, FinishTaskEventLog.class);
}
@Override
public List findAllFinishTaskEventLogsByCaseId(String caseId) {
return findAllByCaseId(caseId, FinishTaskEventLog.class);
}
@Override
public Page findByUserId(String id, Class clazz, Pageable pageable) {
String queryString = "{userId: '" + id + this.clazz + clazz.getName() + "'}";
return findByQuery(queryString, clazz, pageable);
}
@Override
public List findAllByUserId(String id, Class clazz) {
String queryString = "{userId: '" + id + this.clazz + clazz.getName() + "'}";
Query query = new BasicQuery(queryString);
return findAllByQuery(query, clazz);
}
@Override
public Page findByNetId(String id, Class clazz, Pageable pageable) {
return findByNetId(new ObjectId(id), clazz, pageable);
}
@Override
public List findAllByNetId(String id, Class clazz) {
return findAllByNetId(new ObjectId(id), clazz);
}
@Override
public Page findByNetId(ObjectId id, Class clazz, Pageable pageable) {
String queryString = "{netId: '" + id + this.clazz + clazz.getName() + "'}";
return findByQuery(queryString, clazz, pageable);
}
@Override
public List findAllByNetId(ObjectId id, Class clazz) {
String queryString = "{netId: '" + id + this.clazz + clazz.getName() + "'}";
Query query = new BasicQuery(queryString);
return findAllByQuery(query, clazz);
}
@Override
public Page findByTaskId(String id, Class clazz) {
return null;
}
@Override
public Page findByTaskId(String id, Class clazz, Pageable pageable) {
String queryString = "{taskId: '" + id + this.clazz + clazz.getName() + "'}";
return findByQuery(queryString, clazz, pageable);
}
@Override
public List findAllByTaskId(String id, Class clazz) {
String queryString = "{taskId: '" + id + this.clazz + clazz.getName() + "'}";
Query query = new BasicQuery(queryString);
return findAllByQuery(query, clazz);
}
@Override
public Page findByCaseId(String id, Class clazz, Pageable pageable) {
String queryString = "{caseId: '" + id + this.clazz + clazz.getName() + "'}";
return findByQuery(queryString, clazz, pageable);
}
@Override
public List findAllByCaseId(String id, Class clazz) {
String queryString = "{caseId: '" + id + this.clazz + clazz.getName() + "'}";
Query query = new BasicQuery(queryString);
return findAllByQuery(query, clazz);
}
@Override
public Page findByQuery(Query query, Class clazz, Pageable pageable) {
return null;
}
@Override
public Page findByQuery(String queryString, Class clazz, Pageable pageable) {
Query query = new BasicQuery(queryString).with(pageable);
return new PageImpl<>(mongoTemplate.find(query, clazz),
pageable,
mongoTemplate.count(new BasicQuery(queryString, "{_id:1}"), clazz));
}
@Override
public List findAllByQuery(Query query, Class clazz) {
return mongoTemplate.find(query, clazz);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy