Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addec calendar for event log service #1271

Merged
merged 2 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@

package org.apromore.service;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import org.apromore.apmlog.APMLog;
import org.apromore.calendar.model.CalendarModel;
import org.apromore.commons.config.ConfigBean;
Expand All @@ -36,12 +41,6 @@
import org.apromore.storage.exception.ObjectCreationException;
import org.deckfour.xes.model.XLog;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

/**
* Interface for the Process Service. Defines all the methods that will do the majority of the work
* for the Apromore application.
Expand Down Expand Up @@ -152,4 +151,6 @@ boolean saveFileToVolume(String filename, String prefix,
ByteArrayOutputStream baos) throws Exception;

ConfigBean getConfigBean();

List<Log> getLogListFromCalendarId(Long calendarId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,14 @@ public CalendarModel getCalendarFromLog(Integer logId) {
CustomCalendar calendar = logRepo.findUniqueByID(logId).getCalendar();
return calendar != null ? calendarService.getCalendar(calendar.getId()) : calendarService.getGenericCalendar();
}


@Override
public List<Log> getLogListFromCalendarId(Long calendarId) {
return logRepo.findByCalendarId(calendarId);
}



@Override
public boolean saveFileToVolume(String filename, String prefix, ByteArrayOutputStream baos) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*-
* #%L
* This file is part of "Apromore Core".
* %%
* Copyright (C) 2018 - 2021 Apromore Pty Ltd.
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/
package org.apromore.integration;

import static org.assertj.core.api.Assertions.assertThat;
import java.time.ZoneId;
import java.util.List;
import org.apromore.dao.CustomCalendarRepository;
import org.apromore.dao.LogRepository;
import org.apromore.dao.model.CustomCalendar;
import org.apromore.dao.model.Log;
import org.apromore.service.EventLogService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

public class EventLogServiceTest extends BaseTest {

@Autowired
CustomCalendarRepository calendarRepository;

@Autowired
LogRepository logRepository;

@Autowired
EventLogService eventLogService;

@Test
public void testEventLogsForCalendar() {
// Given
CustomCalendar calendar = new CustomCalendar("Test Calendar for log", ZoneId.of("UTC"));
calendar = calendarRepository.saveAndFlush(calendar);
assertThat(calendar.getId()).isNotNull();
Log log1=createLog("log1",calendar);
Log log2=createLog("log2",calendar);

log1=logRepository.saveAndFlush(log1);
log2=logRepository.saveAndFlush(log2);
assertThat(log1.getId()).isNotNull();
assertThat(log2.getId()).isNotNull();
// When

List<Log> logs= eventLogService.getLogListFromCalendarId(calendar.getId());

// Then
assertThat(logs).hasSize(2);
assertThat(logs).extracting("name").contains(log1.getName(),log2.getName());


}

private Log createLog(String name,CustomCalendar calendar) {
Log log1=new Log();
log1.setName(name);
log1.setFilePath(name);
log1.setCalendar(calendar);
return log1;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package org.apromore.dao;

import java.util.List;

import org.apromore.dao.model.Log;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -102,6 +101,8 @@ public interface LogRepository extends JpaRepository<Log, Integer>, LogRepositor
@Query("SELECT DISTINCT l FROM Log l WHERE l.folder.id in ?1")
List<Log> findByFolderIdIn(List<Integer> folderIds);

List<Log> findByCalendarId(Long calendarId);

// /**
// * Returns a list of processIds
// * @param folderId the id of the folder
Expand Down