Config worksgit add .git add .
This commit is contained in:
		@@ -9,6 +9,7 @@ import com.plannaplan.models.FileData;
 | 
			
		||||
import com.plannaplan.services.CourseService;
 | 
			
		||||
import com.plannaplan.services.GroupService;
 | 
			
		||||
import com.plannaplan.services.LecturerService;
 | 
			
		||||
import com.plannaplan.types.GroupType;
 | 
			
		||||
import com.plannaplan.types.WeekDay;
 | 
			
		||||
 | 
			
		||||
import org.apache.poi.ss.usermodel.Cell;
 | 
			
		||||
@@ -78,20 +79,12 @@ public class FileToDatabaseMigrator {
 | 
			
		||||
            int day = (int) Double.parseDouble(day_cell.toString());
 | 
			
		||||
            WeekDay group_day = WeekDay.getDay(day);
 | 
			
		||||
            String room = room_cell.toString();
 | 
			
		||||
            int time = 480;
 | 
			
		||||
            int time = this.parseTimeToInt(time_cell.toString());
 | 
			
		||||
 | 
			
		||||
            int capacity = (int) Double.parseDouble(capacity_cell.toString());
 | 
			
		||||
 | 
			
		||||
            Groups group = groupService.find(time, capacity, room);
 | 
			
		||||
 | 
			
		||||
            if (group == null) {
 | 
			
		||||
                group = new Groups();
 | 
			
		||||
                group.setCapacity(capacity);
 | 
			
		||||
                group.setTime(time);
 | 
			
		||||
                group.setRoom(room);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            groupService.save(group);
 | 
			
		||||
 | 
			
		||||
            Course course = this.courseService.getCourseByName(course_name);
 | 
			
		||||
 | 
			
		||||
            if (course == null) {
 | 
			
		||||
@@ -112,12 +105,44 @@ public class FileToDatabaseMigrator {
 | 
			
		||||
                lecturer_surname = surname_cell.toString();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (lecturerService.getLecturer(lecturer_title, lecturer_name, lecturer_surname) == null) {
 | 
			
		||||
                Lecturer newLecturer = new Lecturer(lecturer_title, lecturer_name, lecturer_surname);
 | 
			
		||||
                lecturerService.save(newLecturer);
 | 
			
		||||
            Lecturer lecturer = lecturerService.getLecturer(lecturer_title, lecturer_name, lecturer_surname);
 | 
			
		||||
 | 
			
		||||
            if (lecturer == null) {
 | 
			
		||||
                lecturer = new Lecturer(lecturer_title, lecturer_name, lecturer_surname);
 | 
			
		||||
                lecturerService.save(lecturer);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (group == null) {
 | 
			
		||||
                group = new Groups();
 | 
			
		||||
                group.setCapacity(capacity);
 | 
			
		||||
                group.setRoom(room);
 | 
			
		||||
                group.setCourseId(course);
 | 
			
		||||
                group.setTime(time);
 | 
			
		||||
                if (capacity >= 50) {
 | 
			
		||||
                    group.setType(GroupType.LECTURE);
 | 
			
		||||
                } else {
 | 
			
		||||
                    group.setType(GroupType.CLASS);
 | 
			
		||||
                }
 | 
			
		||||
                group.setDay(group_day);
 | 
			
		||||
                group.setLecturer(lecturer);
 | 
			
		||||
 | 
			
		||||
                groupService.save(group);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private Integer parseTimeToInt(String time) {
 | 
			
		||||
        String times[] = time.split("\\.");
 | 
			
		||||
        if (times.length == 2) {
 | 
			
		||||
            return Integer.parseInt(times[0]) * 60 + Integer.parseInt(times[1]);
 | 
			
		||||
        }
 | 
			
		||||
        times = time.split("\\:");
 | 
			
		||||
        if (times.length == 2) {
 | 
			
		||||
            return Integer.parseInt(times[0]) * 60 + Integer.parseInt(times[1]);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -9,6 +9,6 @@ import org.springframework.stereotype.Repository;
 | 
			
		||||
 | 
			
		||||
@Repository
 | 
			
		||||
public interface GroupRepository extends JpaRepository<Groups, Long> {
 | 
			
		||||
    @Query(value = "SELECT * FROM groups WHERE name = :name AND surname = :surname AND title = :title ", nativeQuery = true)
 | 
			
		||||
    @Query(value = "SELECT * FROM groups WHERE time = :time AND room = :room AND capacity = :capacity ", nativeQuery = true)
 | 
			
		||||
    Groups find(@Param("time") int time, @Param("room") String room, @Param("capacity") int capacity);
 | 
			
		||||
}
 | 
			
		||||
@@ -11,6 +11,9 @@ public class GroupService {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private GroupRepository repo;
 | 
			
		||||
 | 
			
		||||
    public GroupService() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Groups find(int time, int capacity, String room) {
 | 
			
		||||
        return this.repo.find(time, room, capacity);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user