OrderRequestActionService.java

/*
 * Copyright 2020 Global Crop Diversity Trust
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gringlobal.service;

import java.util.List;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;

import org.gringlobal.model.OrderRequest;
import org.gringlobal.model.OrderRequestAction;
import org.gringlobal.model.OrderRequestItem;
import org.gringlobal.service.OrderRequestActionService.OrderRequestActionRequest;
import org.gringlobal.service.OrderRequestActionService.OrderRequestActionScheduleFilter;
import org.gringlobal.service.filter.OrderRequestActionFilter;
import org.gringlobal.service.filter.OrderRequestFilter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

/**
 * @author Maxym Borodenko
 */
public interface OrderRequestActionService extends ActionService<OrderRequestAction, OrderRequestActionFilter, OrderRequestActionRequest, OrderRequestActionScheduleFilter> {

	@NoArgsConstructor
	@SuperBuilder
	public static class OrderRequestActionRequest extends ActionService.ActionRequest {
		public Double actionCost;
		public String actionInformation;
	}

	@Setter
	@Getter
	@Accessors(fluent = true)
	class OrderRequestActionScheduleFilter extends ActionService.ActionScheduleFilter<OrderRequestActionScheduleFilter, OrderRequestAction> {
		private static final long serialVersionUID = -384520835609810328L;
		public OrderRequestFilter orderRequest;
	}

	/**
	 * Log an action.
	 *
	 * @param orderRequest the order request
	 * @param note the note
	 * @param updatedItems the items
	 */
	void logAction(OrderRequest orderRequest, String note, List<OrderRequestItem> updatedItems);

	/**
	 * List of all records by order request
	 *
	 * @param orderRequest the order request
	 * @return the page
	 */
	Page<OrderRequestAction> listByOrderRequest(OrderRequest orderRequest, Pageable pageable);

}