OrderRequestItemActionService.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 org.gringlobal.custom.validation.javax.CodeValueField;
import org.gringlobal.model.OrderRequest;
import org.gringlobal.model.OrderRequestItemAction;
import org.gringlobal.model.community.CommunityCodeValues;
import org.gringlobal.service.OrderRequestItemActionService.OrderRequestItemActionRequest;
import org.gringlobal.service.OrderRequestItemActionService.OrderRequestItemActionScheduleFilter;
import org.gringlobal.service.filter.OrderRequestItemActionFilter;
import org.gringlobal.service.filter.OrderRequestItemFilter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * @author Maxym Borodenko
 */
public interface OrderRequestItemActionService extends ActionService<OrderRequestItemAction, OrderRequestItemActionFilter, OrderRequestItemActionRequest, OrderRequestItemActionScheduleFilter> {

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

	class OrderRequestItemActionScheduleFilter extends ActionService.ActionScheduleFilter<OrderRequestItemActionScheduleFilter, OrderRequestItemAction> {
		private static final long serialVersionUID = 394794380324680608L;
		public OrderRequestItemFilter orderRequestItem;
	}


	/**
	 * Start an action for all items in the request
	 *
	 * @param orderRequest
	 * @param actionCode the managed action to initiate
	 * @return
	 */
	List<OrderRequestItemAction> startActions(OrderRequest orderRequest, @CodeValueField(CommunityCodeValues.ORDER_REQUEST_ITEM_ACTION) String actionCode);

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

}