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 1 commit
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
Next Next commit
Addec calendar for event log service
  • Loading branch information
Nolan Tellis committed Sep 13, 2021
commit c9756e63aceccd41e84942e93fcda27682a4f3de
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
@@ -1,3 +1,24 @@
/*-
* #%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.dao;

import org.apromore.dao.model.DbConnectorDao;
Expand Down
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
/*-
* #%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.dao.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Entity
@Table(name = "db_connector")
@Data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/**
* #%L
* This file is part of "Apromore Enterprise Edition".
* %%
* Copyright (C) 2019 - 2021 Apromore Pty Ltd. All Rights Reserved.
* %%
* NOTICE: All information contained herein is, and remains the
* property of Apromore Pty Ltd and its suppliers, if any.
* The intellectual and technical concepts contained herein are
* proprietary to Apromore Pty Ltd and its suppliers and may
* be covered by U.S. and Foreign Patents, patents in process,
* and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this
* material is strictly forbidden unless prior written permission
* is obtained from Apromore Pty Ltd.
* #L%
*/
package org.apromore.dao.jpa.etl;

import org.apromore.config.BaseTestClass;
Expand Down