InvitroInventoryService.java

/*
 * Copyright 2022 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 javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

import org.gringlobal.custom.validation.javax.CodeValueField;
import org.gringlobal.custom.validation.javax.OneLine;
import org.gringlobal.custom.validation.javax.SimpleString;
import org.gringlobal.model.Inventory;
import org.gringlobal.model.InventoryMaintenancePolicy;
import org.gringlobal.model.Materiel;
import org.gringlobal.model.community.CommunityCodeValues;

/**
 * Services for in vitro collections.
 */
public interface InvitroInventoryService {

	class IVMultiplicationRequest {
		@NotNull
		public Inventory sourceInventory;
		@Min(0)
		public int quantityToDeduct;
		@NotNull
		public List<IVMultiplicationItem> multiplicationItems;
	}

	class IVMultiplicationItem {
		public String inventoryNumberPart1;

		@OneLine
		@SimpleString
		public String inventoryNumberPart3;

		@CodeValueField(CommunityCodeValues.GERMPLASM_FORM)
		public String formTypeCode;

		@CodeValueField(CommunityCodeValues.CONTAINER_TYPE)
		public String containerTypeCode;

		@Min(0)
		public Double quantityOnHand;

		@CodeValueField(CommunityCodeValues.UNIT_OF_QUANTITY)
		public String quantityOnHandUnitCode;

		@NotNull
		public InventoryMaintenancePolicy inventoryMaintenancePolicy;

		public Materiel medium;

		@Pattern(regexp = "^Y|N$")
		public String isAutoDeducted = "Y";
	}

	/**
	 * Initiate the introduction of new material for in vitro conservation
	 * 
	 * @return List of registered inventories
	 */
	List<Inventory> invitroStart(@Valid IVMultiplicationRequest request);

	/**
	 * Multiply existing in vitro Inventory,
	 * similar to {@link InventoryService#splitInventory(org.gringlobal.service.InventoryService.SplitInventoryRequest)}.
	 *
	 * @return
	 */
	List<Inventory> invitroMultiply(@Valid IVMultiplicationRequest request);

}